ezEngine  Milestone 9
ezResourceLock< RESOURCE_TYPE > Class Template Reference

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

#include <ResourceLock.h>

Public Member Functions

EZ_ALWAYS_INLINE ezResourceLock (const ezTypedResourceHandle< RESOURCE_TYPE > &hResource, ezResourceAcquireMode mode, const ezTypedResourceHandle< RESOURCE_TYPE > &hFallbackResource=ezTypedResourceHandle< RESOURCE_TYPE >(), ezResourcePriority Priority=ezResourcePriority::Unchanged)
EZ_ALWAYS_INLINE const RESOURCE_TYPE * operator-> () const
EZ_ALWAYS_INLINE bool IsValid () const
EZ_ALWAYS_INLINE operator bool () const
EZ_ALWAYS_INLINE ezResourceAcquireResult GetAcquireResult () const
EZ_ALWAYS_INLINE const RESOURCE_TYPE * GetPointer () const

Detailed Description

template<class RESOURCE_TYPE>
class ezResourceLock< RESOURCE_TYPE >

Helper class to acquire and release a resource safely.

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

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

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 ezResourceAcquireMode::NoFallbackAllowMissing. Only then will the error be silently ignored and the acquire result will be ezResourceAcquireResult::None.
See also

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