Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scine::Molassembler::Temple::Cache< KeyType > Class Template Reference

#include <Cache.h>

Public Member Functions

Constructors
 Cache ()=default
 
 Cache (const std::initializer_list< std::pair< KeyType, std::function< boost::any() > > > &initList)
 
Modification
template<typename T >
void add (const KeyType &key, const T &value)
 Adds a data value for a key value into the cache.
 
template<typename T >
getGeneratable (const KeyType &key)
 
template<typename T >
void changeGeneratable (const KeyType &key, std::function< > modifyingUnaryFunction)
 Permits the modification of a generatable cache item via a raw pointer.
 
void invalidate ()
 Invalidates the entire cache, removing all stored data.
 
void invalidate (const KeyType &key)
 Selectively invalidates cache entries.
 
Information
template<typename T >
boost::optional< T > getOption (const KeyType &key) const
 Fetches a cache entry via an optional.
 
bool has (const KeyType &key) const
 Tests whether the cache contains an entry for a key.
 

Private Attributes

std::map< KeyType, boost::any > cache_
 Cache data.
 
std::map< KeyType,
std::function< boost::any()> > 
generationMap_
 Map of key values to generating functions.
 

Detailed Description

template<typename KeyType>
class Scine::Molassembler::Temple::Cache< KeyType >

A class that can store completely variant types in a type safe manner using boost::any. Only the key type is fixed. Selective invalidation of cached data is possible, and cache elements can also be set as generatable, i.e. a function that generates the cache data can be passed. On first use, the cache element is then generated.

Member Function Documentation

template<typename KeyType >
template<typename T >
T Scine::Molassembler::Temple::Cache< KeyType >::getGeneratable ( const KeyType &  key)
inline

Fetches the value of a generatable cache item. Handles all corner cases of whether the cache element is present or not.


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