Cogs.Core
|
Resource handle base class handling reference counting of resources derived from ResourceBase. More...
#include <ResourceHandle.h>
Public Member Functions | |
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 ResourceHandleBase | NoHandle = Cogs::Core::ResourceHandleBase(nullptr) |
Provided as shorthand for empty resource handles. | |
Protected Member Functions | |
void | resetInternal (ResourceBase *otherResource) |
Reset the contents of this instance to the given handle and resource. | |
Protected Attributes | |
ResourceBase * | resource = nullptr |
Pointer to held resource. | |
Resource handle base class handling reference counting of resources derived from ResourceBase.
Definition at line 18 of file ResourceHandle.h.
|
inline |
Constructs a handle with the given integer handle and resource pointer pair.
resource | Pointer to the resource itself. |
Definition at line 28 of file ResourceHandle.h.
|
inline |
Copy constructs a handle from the given other handle.
other | A handle to copy contents from. |
Definition at line 38 of file ResourceHandle.h.
References resource.
|
inlinenoexcept |
Move constructs a handle from the given other handle.
The other handle is left empty after construction.
other | A handle to move contents from. |
Definition at line 48 of file ResourceHandle.h.
Cogs::Core::ResourceHandleBase::~ResourceHandleBase | ( | ) |
Destructs a handle, and if a resource is held, releases the reference to this resource.
Definition at line 7 of file ResourceHandle.cpp.
References Cogs::Core::ResourceBase::decrement(), and resource.
|
inline |
Definition at line 108 of file ResourceHandle.h.
|
inline |
Definition at line 110 of file ResourceHandle.h.
ResourceId Cogs::Core::ResourceHandleBase::getId | ( | ) | const |
Get the resource id of the held resource.
Definition at line 19 of file ResourceHandle.cpp.
|
inline |
Definition at line 128 of file ResourceHandle.h.
|
inline |
Implicit bool conversion operator.
Used to simplify checking for the validity of a handle.
Using the operator, checking a handles validity is similar to checking a pointer:
Definition at line 102 of file ResourceHandle.h.
|
inline |
Compares this instance against other for inequality.
other | A handle to compare against. |
Definition at line 85 of file ResourceHandle.h.
|
inline |
Definition at line 105 of file ResourceHandle.h.
|
inline |
Definition at line 106 of file ResourceHandle.h.
|
inline |
Assign the handle from the given other handle.
other | A handle to copy contents from. |
Definition at line 65 of file ResourceHandle.h.
References resource.
Referenced by Cogs::Core::ResourceHandle_t< ResourceType >::operator=().
|
inline |
Compares this instance against the contents of other.
other | A handle to compare contents with. |
Definition at line 75 of file ResourceHandle.h.
References resource.
void Cogs::Core::ResourceHandleBase::reset | ( | ResourceBase * | otherResource | ) |
Reset the contents of this instance to the given handle and resource.
This will release reference to a held resource if present, and take up ownership of the newly assigned resource.
otherResource | Pointer to a resource which this handle will assume shared ownership over. |
Definition at line 12 of file ResourceHandle.cpp.
References Cogs::Core::ResourceBase::increment().
|
protected |
Reset the contents of this instance to the given handle and resource.
This will release reference to a held resource if present, and take up ownership of the newly assigned resource.
otherResource | Pointer to a resource which this handle will assume shared ownership over. |
Definition at line 21 of file ResourceHandle.cpp.
|
static |
Provided as shorthand for empty resource handles.
Definition at line 123 of file ResourceHandle.h.
Referenced by Cogs::Core::ResourceManagerBase::getResourceHandle(), and Cogs::Core::ResourceManagerBase::releaseInternal().
|
protected |
Pointer to held resource.
Definition at line 144 of file ResourceHandle.h.
Referenced by Cogs::Core::ResourceHandle_t< ResourceType >::operator->(), operator=(), operator==(), Cogs::Core::ResourceHandle_t< ResourceType >::resolve(), ResourceHandleBase(), and ~ResourceHandleBase().