A templated class used to cache ressources, indexed with a string.
More...
#include <Cache.hpp>
|
| | Cache (std::function< T(const char *)> dataLoader, std::function< void(T)> dataUnloader) |
| |
| | ~Cache ()=default |
| | Default destructor, will destroy ray's data. More...
|
| |
| | Cache (const Cache &)=default |
| | default copy constructor More...
|
| |
| Cache & | operator= (const Cache &)=default |
| | a cache is assignable More...
|
| |
| std::shared_ptr< T > | fetch (const std::string &path, bool lonely=false) |
| |
|
| std::function< T(const char *)> | _dataLoader |
| | function to call to load data More...
|
| |
| std::function< void(T)> | _dataUnloader |
| | function to call when the ray data will be unloaded More...
|
| |
| std::unordered_map< std::string, std::vector< std::shared_ptr< T > > > | _cache |
| | map storing shared ptr of caches More...
|
| |
template<typename T>
class RAY::Cache< T >
A templated class used to cache ressources, indexed with a string.
◆ Cache() [1/2]
template<typename T >
| RAY::Cache< T >::Cache |
( |
std::function< T(const char *)> |
dataLoader, |
|
|
std::function< void(T)> |
dataUnloader |
|
) |
| |
|
inline |
◆ ~Cache()
Default destructor, will destroy ray's data.
◆ Cache() [2/2]
◆ fetch()
template<typename T >
| std::shared_ptr<T> RAY::Cache< T >::fetch |
( |
const std::string & |
path, |
|
|
bool |
lonely = false |
|
) |
| |
|
inline |
- Parameters
-
| path | path of the file |
| lonely | should be set to true if the loaded data must be held by no other active entites |
- Returns
- a newly loaded ressource if it hasn't be previously loaded, or one from cache
◆ operator=()
◆ _cache
template<typename T >
| std::unordered_map<std::string, std::vector<std::shared_ptr<T> > > RAY::Cache< T >::_cache |
|
private |
map storing shared ptr of caches
◆ _dataLoader
template<typename T >
| std::function<T(const char *)> RAY::Cache< T >::_dataLoader |
|
private |
function to call to load data
◆ _dataUnloader
template<typename T >
| std::function<void(T)> RAY::Cache< T >::_dataUnloader |
|
private |
function to call when the ray data will be unloaded
The documentation for this class was generated from the following file: