SyTen
syten::Cached< Type > Class Template Reference

Caching/cached type. More...

#include <cached_type.h>

+ Inheritance diagram for syten::Cached< Type >:
+ Collaboration diagram for syten::Cached< Type >:

Public Member Functions

MemoryUsage::MemorySize allocSize () const
 allocSize() More...
 
bool cache () const
 Caches the contained object into the file. More...
 
 Cached ()=default
 Default ctor, only valid if Type is default-constructible. More...
 
template<typename... Args, typename std::enable_if<!std::is_same< typename std::decay< Args... >::type, typename std::decay< Cached< Type > >::type >::value, int >::type = 0>
 Cached (Args &&... _args)
 Direct ctor for the contained type. More...
 
 Cached (Cached &&other)
 Move ctor. More...
 
 Cached (Cached const &other)
 Copy ctor. More...
 
 Cached (Type &&_data)
 Ctor from an object of the contained type. More...
 
bool isCached () const
 Returns true if the object is currently cached on disk. More...
 
bool load () const
 Same as uncache() More...
 
bool maybeCache (bool do_it) const
 Caches the object onto disk if do_it is true. More...
 
Type & operator() ()
 Loads the object from disk if necessary and returns a reference to it. More...
 
Type const & operator() () const
 Loads the object from disk if necessary and returns a const reference to it. More...
 
Cachedoperator= (Cached &&other)
 Move assignment operator. More...
 
Cachedoperator= (Cached const &other)
 Copy assignment operator. More...
 
bool uncache () const
 Uncaches/loads the contained object from the file. More...
 
 ~Cached ()
 Dtor. More...
 
Boost serialisation
template<class Archive >
void save (Archive &ar, const unsigned int) const
 Saving into a boost archive. More...
 
template<class Archive >
void load (Archive &ar, const unsigned int in_version) const
 Loading from a boost archive. More...
 

Static Public Attributes

static constexpr unsigned int version = 1
 Boost serialisation version. More...
 

Private Attributes

Type data
 The wrapped object. More...
 
std::string file
 Name of the file on disk. More...
 
std::recursive_mutex mtex
 Mutex protecting us. More...
 

Detailed Description

template<typename Type>
class syten::Cached< Type >

Caching/cached type.

Objects are stored on disk or retrieved from disk on request only.


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