Plasma Engine  2.0
Loading...
Searching...
No Matches
plResourceLock< RESOURCE_TYPE > Class Template Reference

Helper class to acquire and release a resource safely. More...

#include <ResourceLock.h>

Public Member Functions

PL_ALWAYS_INLINE plResourceLock (const plTypedResourceHandle< RESOURCE_TYPE > &hResource, plResourceAcquireMode mode, const plTypedResourceHandle< RESOURCE_TYPE > &hFallbackResource=plTypedResourceHandle< RESOURCE_TYPE >())
 
 plResourceLock (const plResourceLock &)=delete
 
 plResourceLock (plResourceLock &&other)
 
PL_ALWAYS_INLINE RESOURCE_TYPE * operator-> ()
 
PL_ALWAYS_INLINE const RESOURCE_TYPE * operator-> () const
 
PL_ALWAYS_INLINE bool IsValid () const
 
PL_ALWAYS_INLINE operator bool () const
 
PL_ALWAYS_INLINE plResourceAcquireResult GetAcquireResult () const
 
PL_ALWAYS_INLINE const RESOURCE_TYPE * GetPointer () const
 
PL_ALWAYS_INLINE RESOURCE_TYPE * GetPointerNonConst () const
 

Detailed Description

template<class RESOURCE_TYPE>
class plResourceLock< RESOURCE_TYPE >

Helper class to acquire and release a resource safely.

The constructor calls plResourceManager::BeginAcquireResource, the destructor makes sure to call plResourceManager::EndAcquireResource. The instance of this class can be used like a pointer to the resource.

Whether the acquisition succeeded or returned a loading fallback, missing fallback or even no result, at all, can be retrieved through GetAcquireResult().

Note
If a resource is missing, but no missing fallback is specified for the resource type, the code will fail with an assertion, unless you used plResourceAcquireMode::BlockTillLoaded_NeverFail. Only then will the error be silently ignored and the acquire result will be plResourceAcquireResult::None.
See also
plResourceManager::BeginAcquireResource()
plResourceAcquireMode
plResourceAcquireResult

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