Rosetta
Public Member Functions | Private Attributes | List of all members
utility::thread::MutableCache< K, V > Class Template Reference

#include <mutable_cache.hh>

Public Member Functions

 MutableCache ()=default
 
 ~MutableCache ()=default
 
 MutableCache (MutableCache const &src)
 
 MutableCache (MutableCache &&src)
 
MutableCacheoperator= (MutableCache const &src)
 
MutableCacheoperator= (MutableCache &&src)
 
bool has (K const &key) const
 
V const & get (K const &key) const
 
void add_if_missing (K const &key, V const &value)
 Add the key:value pair to the map, but only if the key isn't already present. More...
 
void add_if_missing (K const &key, std::function< V() > creator)
 Add a key:value pair to the map if the key isn't present. The creator function will be called to generate the value. More...
 
void add_if_missing (K const &key, std::function< V(K const &) > creator)
 Add a key:value pair to the map if the key isn't present. The creator function will be called to generate the value. More...
 

Private Attributes

std::map< K, Vdata_
 

Constructor & Destructor Documentation

◆ MutableCache() [1/3]

template<class K , class V >
utility::thread::MutableCache< K, V >::MutableCache ( )
default

◆ ~MutableCache()

template<class K , class V >
utility::thread::MutableCache< K, V >::~MutableCache ( )
default

◆ MutableCache() [2/3]

template<class K , class V >
utility::thread::MutableCache< K, V >::MutableCache ( MutableCache< K, V > const &  src)

◆ MutableCache() [3/3]

template<class K , class V >
utility::thread::MutableCache< K, V >::MutableCache ( MutableCache< K, V > &&  src)

Member Function Documentation

◆ add_if_missing() [1/3]

template<class K , class V >
void utility::thread::MutableCache< K, V >::add_if_missing ( K const &  key,
std::function< V() >  creator 
)

Add a key:value pair to the map if the key isn't present. The creator function will be called to generate the value.

References subloop_histogram::key.

◆ add_if_missing() [2/3]

template<class K , class V >
void utility::thread::MutableCache< K, V >::add_if_missing ( K const &  key,
std::function< V(K const &) >  creator 
)

Add a key:value pair to the map if the key isn't present. The creator function will be called to generate the value.

References subloop_histogram::key.

◆ add_if_missing() [3/3]

template<class K , class V >
void utility::thread::MutableCache< K, V >::add_if_missing ( K const &  key,
V const &  value 
)

Add the key:value pair to the map, but only if the key isn't already present.

References subloop_histogram::key, and value.

◆ get()

template<class K , class V >
V const & utility::thread::MutableCache< K, V >::get ( K const &  key) const

◆ has()

template<class K , class V >
bool utility::thread::MutableCache< K, V >::has ( K const &  key) const

◆ operator=() [1/2]

template<class K , class V >
MutableCache< K, V > & utility::thread::MutableCache< K, V >::operator= ( MutableCache< K, V > &&  src)

◆ operator=() [2/2]

template<class K , class V >
MutableCache< K, V > & utility::thread::MutableCache< K, V >::operator= ( MutableCache< K, V > const &  src)

Member Data Documentation

◆ data_

template<class K , class V >
std::map< K, V > utility::thread::MutableCache< K, V >::data_
private

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