Cogs.Core
|
Opaque resource handle for holding references to resources. More...
#include <ResourceHandle.h>
Public Member Functions | |
ResourceHandle_t ()=default | |
Default construct a resource handle. | |
ResourceHandle_t (ResourceBase *resource) | |
Constructs a handle from the given resource pointer. | |
ResourceHandle_t (const ResourceHandle_t &other) | |
Copy construct a handle. | |
ResourceHandle_t (ResourceHandle_t &&other) noexcept | |
Move construct a handle from the given r-value. | |
ResourceHandle_t & | operator= (const ResourceHandle_t &other) |
Copy assign the handle from the given other handle. | |
ResourceHandle_t (const ResourceHandleBase &other) | |
ResourceType * | resolve () const |
Resolve the handle, returning a pointer to the actual resource. | |
ResourceType * | operator-> () const |
Pointer operator, returns the held resource. | |
![]() | |
ResourceHandleBase ()=default | |
Constructs an empty handle, holding no resource. | |
ResourceHandleBase (ResourceBase *resource) | |
Constructs a handle with the given integer handle and resource pointer pair. | |
ResourceHandleBase (const ResourceHandleBase &other) | |
Copy constructs a handle from the given other handle. | |
ResourceHandleBase (ResourceHandleBase &&other) noexcept | |
Move constructs a handle from the given other handle. | |
~ResourceHandleBase () | |
Destructs a handle, and if a resource is held, releases the reference to this resource. | |
ResourceHandleBase & | operator= (const ResourceHandleBase &other) |
Assign the handle from the given other handle. | |
bool | operator== (const ResourceHandleBase &other) const |
Compares this instance against the contents of other. | |
bool | operator!= (const ResourceHandleBase &other) const |
Compares this instance against other for inequality. | |
operator bool () const | |
Implicit bool conversion operator. | |
ResourceBase * | operator-> () |
const ResourceBase * | operator-> () const |
ResourceBase * | get () |
const ResourceBase * | get () const |
void | reset (ResourceBase *otherResource) |
Reset the contents of this instance to the given handle and resource. | |
ResourceId | getId () const |
Get the resource id of the held resource. | |
size_t | hash (size_t hashValue=Cogs::hash()) const |
Static Public Attributes | |
static const ResourceHandle_t | NoHandle = ResourceHandle_t<T>(nullptr) |
Handle representing a default (or none if default not present) resource. | |
![]() | |
static const ResourceHandleBase | NoHandle = Cogs::Core::ResourceHandleBase(nullptr) |
Provided as shorthand for empty resource handles. | |
Friends | |
struct | std::hash< ResourceHandle_t< ResourceType > > |
Additional Inherited Members | |
![]() | |
void | resetInternal (ResourceBase *otherResource) |
Reset the contents of this instance to the given handle and resource. | |
![]() | |
ResourceBase * | resource = nullptr |
Pointer to held resource. | |
Opaque resource handle for holding references to resources.
Holding a handle to a resource ensures the resource will not be deleted while in use by keeping automatic reference count.
ResourceType | Type of the resource to manage. Must inherit from ResourceBase. |
Definition at line 154 of file ResourceHandle.h.
|
inlineexplicit |
Constructs a handle from the given resource pointer.
Definition at line 160 of file ResourceHandle.h.
|
inline |
Copy construct a handle.
Definition at line 163 of file ResourceHandle.h.
|
inlinenoexcept |
Move construct a handle from the given r-value.
Definition at line 166 of file ResourceHandle.h.
|
inline |
Definition at line 171 of file ResourceHandle.h.
|
inline |
Pointer operator, returns the held resource.
Definition at line 190 of file ResourceHandle.h.
References Cogs::Core::ResourceHandleBase::resource.
|
inline |
Copy assign the handle from the given other handle.
Definition at line 169 of file ResourceHandle.h.
References Cogs::Core::ResourceHandleBase::operator=().
|
inline |
Resolve the handle, returning a pointer to the actual resource.
The resource is guaranteed to be alive as long as the handle exists.
Definition at line 182 of file ResourceHandle.h.
References Cogs::Core::ResourceHandleBase::resource.
Referenced by Cogs::Core::MaterialInstanceManager::createMaterialInstance(), Cogs::Core::SeaCurrentsSystem::initialize(), Cogs::Core::MarkerPointSetSystem::initialize(), Cogs::Core::InstancedMeshPicker::pickImpl(), Cogs::Core::EchoSounder::UniformGridSystem::preUpdate(), Cogs::Core::DepthAxisSystem::update(), Cogs::Core::InstancedMeshRenderSystem::update(), Cogs::Core::RenderSystem::update(), Cogs::Core::SubMeshRenderSystem::update(), and Cogs::Core::Text3DSystem::update().
|
friend |
Definition at line 193 of file ResourceHandle.h.
|
static |
Handle representing a default (or none if default not present) resource.
Provided as shorthand for empty resource handles.
Definition at line 193 of file ResourceHandle.h.