CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::ResourceHandleData Class Referencefinal

#include <CeresEngine/Resource/ResourceHandle.hpp>

Public Member Functions

 ResourceHandleData (ResourceManager &manager, const UUID &uuid, ResourcePtr &&resource=nullptr)
 Creates a new resource handle data.
 
 ResourceHandleData (const UUID &uuid, ResourcePtr &&resource=nullptr)
 Creates a new resource handle data.
 
 ~ResourceHandleData ()
 Destroys the resource handle data and notifies the manager that it is being destroyed.
 
const UUIDgetUUID () const noexcept
 The resource UUID the handle is representing.
 
ResourcegetResource () const noexcept
 The resource being managed by the resource handle, if any.
 
const ResourcePtrgetResourcePointer () const noexcept
 The resource being managed by the resource handle, if any.
 

Private Member Functions

void strongRetain ()
 Retains the strong resource count.
 
void strongRelease ()
 Releases the strong resource count.
 
void weakRetain ()
 Retains the weak resource count.
 
void weakRelease ()
 Releases the weak resource count.
 
void setResource (ResourcePtr &&resource)
 Changes the resource instance.
 
void notifyStrongRelease ()
 Notifies the ResourceManager that all strong ResourceHandles have been destroyed and the manager can unload the resource if possible.
 

Private Attributes

ResourceManagermResourceManager = nullptr
 The resource manager that the handle belongs to.
 
const UUID mUUID
 The resource UUID the handle is representing.
 
ResourcePtr mResource
 The resource being managed by the resource handle, if any.
 
RefCounter mReferenceCounter
 A reference counter that counts the number of total references (strong + weak) to the resource.
 
RefCounter mStrongReferenceCounter
 A reference counter that counts the number of strong references to the resource.
 
Event< void(const HResource &)> didLoadResource
 An event fired whenever the resource is loaded.
 
Event< void(const HResource &)> didUnloadResource
 An event fired whenever the resource is unloaded.
 

Friends

class ResourceManager
 
class AbstractResourceHandle
 
template<typename T >
class ResourceHandle
 
template<typename T >
class WeakResourceHandle
 

Constructor & Destructor Documentation

◆ ResourceHandleData() [1/2]

CeresEngine::ResourceHandleData::ResourceHandleData ( ResourceManager manager,
const UUID uuid,
ResourcePtr &&  resource = nullptr 
)
inlineexplicit

Creates a new resource handle data.

Parameters
managerThe resource manager that the handle belongs to.
uuidThe UUID for the resource.
resourceThe pre-existing resource. Can be nullptr.

◆ ResourceHandleData() [2/2]

CeresEngine::ResourceHandleData::ResourceHandleData ( const UUID uuid,
ResourcePtr &&  resource = nullptr 
)
inlineexplicit

Creates a new resource handle data.

Parameters
uuidThe UUID for the resource.
resourceThe pre-existing resource. Can be nullptr.

◆ ~ResourceHandleData()

CeresEngine::ResourceHandleData::~ResourceHandleData ( )

Destroys the resource handle data and notifies the manager that it is being destroyed.

Member Function Documentation

◆ getResource()

Resource * CeresEngine::ResourceHandleData::getResource ( ) const
inlinenoexcept

The resource being managed by the resource handle, if any.

If set, it means that the resource is fully loaded and available for usage, if nullptr, then it means that the resource is not loaded.

◆ getResourcePointer()

const ResourcePtr & CeresEngine::ResourceHandleData::getResourcePointer ( ) const
inlinenoexcept

The resource being managed by the resource handle, if any.

If set, it means that the resource is fully loaded and available for usage, if nullptr, then it means that the resource is not loaded.

◆ getUUID()

const UUID & CeresEngine::ResourceHandleData::getUUID ( ) const
inlinenoexcept

The resource UUID the handle is representing.

Once set, the handle cannot represent another UUID.

◆ notifyStrongRelease()

void CeresEngine::ResourceHandleData::notifyStrongRelease ( )
private

Notifies the ResourceManager that all strong ResourceHandles have been destroyed and the manager can unload the resource if possible.

◆ setResource()

void CeresEngine::ResourceHandleData::setResource ( ResourcePtr &&  resource)
private

Changes the resource instance.

Parameters
resourceThe resource to change the handle to.

◆ strongRelease()

void CeresEngine::ResourceHandleData::strongRelease ( )
private

Releases the strong resource count.

Usually called automatically by ResourceHandle object. Must be matched by a call to strongRetain().

◆ strongRetain()

void CeresEngine::ResourceHandleData::strongRetain ( )
private

Retains the strong resource count.

Usually called automatically by ResourceHandle object. Must be matched by a call to strongRelease().

◆ weakRelease()

void CeresEngine::ResourceHandleData::weakRelease ( )
private

Releases the weak resource count.

Usually called automatically by WeakResourceHandle object. Must be matched by a call to weakRetain().

◆ weakRetain()

void CeresEngine::ResourceHandleData::weakRetain ( )
private

Retains the weak resource count.

Usually called automatically by WeakResourceHandle object. Must be matched by a call to weakRelease().

Friends And Related Symbol Documentation

◆ AbstractResourceHandle

◆ ResourceHandle

template<typename T >
friend class ResourceHandle
friend

◆ ResourceManager

◆ WeakResourceHandle

Member Data Documentation

◆ didLoadResource

Event<void(const HResource&)> CeresEngine::ResourceHandleData::didLoadResource
private

An event fired whenever the resource is loaded.

◆ didUnloadResource

Event<void(const HResource&)> CeresEngine::ResourceHandleData::didUnloadResource
private

An event fired whenever the resource is unloaded.

◆ mReferenceCounter

RefCounter CeresEngine::ResourceHandleData::mReferenceCounter
private

A reference counter that counts the number of total references (strong + weak) to the resource.

Once this counter reaches zero, the resource handle data is deallocated.

◆ mResource

ResourcePtr CeresEngine::ResourceHandleData::mResource
private

The resource being managed by the resource handle, if any.

If set, it means that the resource is fully loaded and available for usage, if nullptr, then it means that the resource is not loaded.

◆ mResourceManager

ResourceManager* CeresEngine::ResourceHandleData::mResourceManager = nullptr
private

The resource manager that the handle belongs to.

◆ mStrongReferenceCounter

RefCounter CeresEngine::ResourceHandleData::mStrongReferenceCounter
private

A reference counter that counts the number of strong references to the resource.

Once this counter reaches zero, the resource will be unloaded by the system.

◆ mUUID

const UUID CeresEngine::ResourceHandleData::mUUID
private

The resource UUID the handle is representing.

Once set, the handle cannot represent another UUID.


The documentation for this class was generated from the following file: