Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Asset::Ref< Key, AssetClass > Class Template Reference

Non-owning handle to an asset record managed by AssetManager. More...

#include <Asset.h>

Collaboration diagram for Asset::Ref< Key, AssetClass >:

Public Types

using RecordType = Record<Key, AssetClass>
using Result = LoadResult<Key, AssetClass>

Public Member Functions

 Ref ()=default
LoadState getState () const
 Gets the current loading state.
bool isLoaded () const
 Checks whether the referenced asset has a loaded payload.
AssetClass * get () const
 Gets the loaded payload.
uint64_t getGeneration () const
 Gets the current record generation.
const std::string & getError () const
 Gets the last load error reported by the record.
std::shared_future< ResultreadyFuture () const
 Gets a future for completion of the current generation.
 operator bool () const
 Checks whether this ref still points to a live record.

Private Member Functions

 Ref (std::shared_ptr< RecordType > record)

Static Private Member Functions

static std::shared_future< ResultexpiredFuture ()

Private Attributes

std::weak_ptr< RecordTyperecord_

Detailed Description

template<typename Key, typename AssetClass>
class Asset::Ref< Key, AssetClass >

Non-owning handle to an asset record managed by AssetManager.

Ref keeps access to an asset's state, payload pointer, completion future, generation, and error string without owning the underlying record. A default-constructed ref or a ref whose manager record has been erased evaluates to false.

Template Parameters
KeyAsset lookup key type.
AssetClassAsset payload type.

Definition at line 179 of file Asset.h.

Member Typedef Documentation

◆ RecordType

template<typename Key, typename AssetClass>
using Asset::Ref< Key, AssetClass >::RecordType = Record<Key, AssetClass>

Definition at line 182 of file Asset.h.

◆ Result

template<typename Key, typename AssetClass>
using Asset::Ref< Key, AssetClass >::Result = LoadResult<Key, AssetClass>

Definition at line 183 of file Asset.h.

Constructor & Destructor Documentation

◆ Ref() [1/2]

template<typename Key, typename AssetClass>
Asset::Ref< Key, AssetClass >::Ref ( )
default

◆ Ref() [2/2]

template<typename Key, typename AssetClass>
Asset::Ref< Key, AssetClass >::Ref ( std::shared_ptr< RecordType > record)
inlineexplicitprivate

Definition at line 259 of file Asset.h.

Member Function Documentation

◆ expiredFuture()

template<typename Key, typename AssetClass>
std::shared_future< Result > Asset::Ref< Key, AssetClass >::expiredFuture ( )
inlinestaticprivate

Definition at line 261 of file Asset.h.

Referenced by Asset::Ref< Asset::MeshPath, Animation >::readyFuture().

Here is the caller graph for this function:

◆ get()

template<typename Key, typename AssetClass>
AssetClass * Asset::Ref< Key, AssetClass >::get ( ) const
inlinenodiscard

Gets the loaded payload.

Returns
Pointer to the asset payload when loaded, otherwise nullptr.

Definition at line 210 of file Asset.h.

◆ getError()

template<typename Key, typename AssetClass>
const std::string & Asset::Ref< Key, AssetClass >::getError ( ) const
inlinenodiscard

Gets the last load error reported by the record.

Returns
Error string, or an empty string when no error exists or the record has expired.

Definition at line 230 of file Asset.h.

◆ getGeneration()

template<typename Key, typename AssetClass>
uint64_t Asset::Ref< Key, AssetClass >::getGeneration ( ) const
inlinenodiscard

Gets the current record generation.

Returns
Generation value, or 0 when the record has expired.

Definition at line 220 of file Asset.h.

◆ getState()

template<typename Key, typename AssetClass>
LoadState Asset::Ref< Key, AssetClass >::getState ( ) const
inlinenodiscard

Gets the current loading state.

Returns
Current record state, or UNLOADED when the record has expired.

Definition at line 191 of file Asset.h.

Referenced by Asset::Ref< Asset::MeshPath, Animation >::isLoaded().

Here is the caller graph for this function:

◆ isLoaded()

template<typename Key, typename AssetClass>
bool Asset::Ref< Key, AssetClass >::isLoaded ( ) const
inlinenodiscard

Checks whether the referenced asset has a loaded payload.

Returns
True when the current state is LOADED.

Definition at line 201 of file Asset.h.

◆ operator bool()

template<typename Key, typename AssetClass>
Asset::Ref< Key, AssetClass >::operator bool ( ) const
inlineexplicitnodiscard

Checks whether this ref still points to a live record.

Returns
True when the referenced record still exists.

Definition at line 251 of file Asset.h.

◆ readyFuture()

template<typename Key, typename AssetClass>
std::shared_future< Result > Asset::Ref< Key, AssetClass >::readyFuture ( ) const
inlinenodiscard

Gets a future for completion of the current generation.

Returns
Shared future that resolves to LoadResult when the generation succeeds or fails.

Definition at line 241 of file Asset.h.

Member Data Documentation

◆ record_

template<typename Key, typename AssetClass>
std::weak_ptr<RecordType> Asset::Ref< Key, AssetClass >::record_
private

Definition at line 274 of file Asset.h.


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Core/Asset.h