RavEngine
Loading...
Searching...
No Matches
RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam > Struct Template Reference

#include <Manager.hpp>

Inheritance diagram for RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >:
[legend]
Collaboration diagram for RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >:
[legend]

Static Public Member Functions

template<typename ... A>
static Ref< T > Get (const key_t &str, A ... extras)
 
template<typename ... A>
static Ref< T > GetWithKey (const key_t &str, unique_key_t unique_key, A ... extras)
 
static void Compact ()
 
static void Clear ()
 

Static Protected Attributes

static UnorderedMap< std::tuple< key_t, unique_key_t >, WeakRef< T > > items
 
static SpinLock mtx
 

Additional Inherited Members

- Public Types inherited from RavEngine::CacheBase
using unique_key_t = uint32_t
 

Detailed Description

template<typename key_t, typename T, bool keyIsConstructionParam = true>
struct RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >

Defines a generic non-owning cache. If the key type is not a parameter in the construction of your object, set the final template parameter to false

Member Function Documentation

◆ Clear()

template<typename key_t , typename T , bool keyIsConstructionParam = true>
static void RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >::Clear ( )
inlinestatic

Remove all items from the cache

◆ Compact()

template<typename key_t , typename T , bool keyIsConstructionParam = true>
static void RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >::Compact ( )
inlinestatic

Reduce the size of the cache by removing expired pointers

◆ Get()

template<typename key_t , typename T , bool keyIsConstructionParam = true>
template<typename ... A>
static Ref< T > RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >::Get ( const key_t &  str,
A ...  extras 
)
inlinestatic

Load object from cache. If the object is not cached in memory, it will be loaded from disk.

Parameters
strthe name of the mesh
extrasadditional arguments to pass to meshasset constructor
Note
The cache does not pay attention to the values of extras. If you need to load a new asset, use GetWithKey where you can pass a unique key identifer. The unique key defaults to zero if accessed via this method.

◆ GetWithKey()

template<typename key_t , typename T , bool keyIsConstructionParam = true>
template<typename ... A>
static Ref< T > RavEngine::GenericWeakReadThroughCache< key_t, T, keyIsConstructionParam >::GetWithKey ( const key_t &  str,
unique_key_t  unique_key,
A ...  extras 
)
inlinestatic

Load object from cache. If the object is not cached in memory, it will be loaded from disk.

Parameters
strthe name of the mesh
unique_keya differentiator to force a new load and identify it later
extrasadditional arguments to pass to meshasset constructor
Note
The cache does not pay attention to the values of extras. If you need to load a new asset, use a different unique key identifier.

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