libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Resource.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace Ship {
6class ResourceManager;
7
15class IResource {
16 public:
18 inline static const std::string gAltAssetPrefix = "alt/";
19
24 IResource(std::shared_ptr<ResourceInitData> initData);
25 virtual ~IResource();
26
31 virtual void* GetRawPointer() = 0;
32
37 virtual size_t GetPointerSize() = 0;
38
44 bool IsDirty();
45
52 void Dirty();
53
58 std::shared_ptr<ResourceInitData> GetInitData();
59
60 private:
61 std::shared_ptr<ResourceInitData> mInitData;
62 bool mIsDirty = false;
63};
64
73template <class T> class Resource : public IResource {
74 public:
76
81 virtual T* GetPointer() = 0;
82
83 void* GetRawPointer() override {
84 return static_cast<void*>(GetPointer());
85 }
86};
87
88} // namespace Ship
Non-templated base interface for all resources managed by the ResourceManager.
Definition Resource.h:15
bool IsDirty()
Returns true if the resource has been marked dirty.
virtual void * GetRawPointer()=0
Returns a type-erased raw pointer to the underlying resource data.
IResource(std::shared_ptr< ResourceInitData > initData)
Constructs an IResource with the given initialization data.
std::shared_ptr< ResourceInitData > GetInitData()
Returns the initialization data used to load this resource.
virtual size_t GetPointerSize()=0
Returns the size (in bytes) of the type pointed to by GetRawPointer().
static const std::string gAltAssetPrefix
Path prefix that identifies an "alt asset" override.
Definition Resource.h:18
void Dirty()
Marks the resource as dirty.
virtual ~IResource()
Typed resource base class that provides a strongly-typed pointer accessor.
Definition Resource.h:73
virtual T * GetPointer()=0
Returns a typed pointer to the resource payload.
void * GetRawPointer() override
Returns a type-erased raw pointer to the underlying resource data.
Definition Resource.h:83
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14