mpqc::Registry< Key, Value > Class Template Reference

Documentation

template<typename Key, typename Value>
class mpqc::Registry< Key, Value >

a syntactically-sweet wrapper of std::map, not thread_safe for writing

Public Types

using container_type = std::map< Key, Value >
 
using value_type = typename container_type::value_type
 
using iterator = typename container_type::iterator
 
using const_iterator = typename container_type::const_iterator
 

Public Member Functions

 Registry ()=default
 
 Registry (const container_type &map)
 
 Registry (Registry const &)=default
 
Registryoperator= (Registry const &)=default
 
 Registry (Registry &&)=default
 
Registryoperator= (Registry &&)=default
 
virtual ~Registry ()
 
const container_typeregistry () const
 return the registry More...
 
void insert (const value_type &val)
 
void insert (const Key &key, const Value &val)
 
void update (const Key &key, const Value &val)
 update value which already exists in registry More...
 
void update (const value_type &val)
 update value which already exists in registry More...
 
virtual void remove (const Key &key)
 
virtual void clear ()
 clears the contents of the registry More...
 
virtual Value * retrieve_ptr (const Key &key)
 
const Value * retrieve_ptr (const Key &key) const
 
bool have (const Key &key) const
 check if have key in registry More...
 
Value & retrieve (const Key &key)
 
const Value & retrieve (const Key &key) const
 
template<typename Pred >
void purge_if (const Pred &p)
 purges all objects if p(value_type) == true More...
 

Protected Attributes

container_type registry_
 

Member Typedef Documentation

◆ const_iterator

template<typename Key , typename Value >
using mpqc::Registry< Key, Value >::const_iterator = typename container_type::const_iterator

◆ container_type

template<typename Key , typename Value >
using mpqc::Registry< Key, Value >::container_type = std::map<Key, Value>

◆ iterator

template<typename Key , typename Value >
using mpqc::Registry< Key, Value >::iterator = typename container_type::iterator

◆ value_type

template<typename Key , typename Value >
using mpqc::Registry< Key, Value >::value_type = typename container_type:: value_type

Constructor & Destructor Documentation

◆ Registry() [1/4]

template<typename Key , typename Value >
mpqc::Registry< Key, Value >::Registry ( )
default

◆ Registry() [2/4]

template<typename Key , typename Value >
mpqc::Registry< Key, Value >::Registry ( const container_type map)
inline

◆ Registry() [3/4]

template<typename Key , typename Value >
mpqc::Registry< Key, Value >::Registry ( Registry< Key, Value > const &  )
default

◆ Registry() [4/4]

template<typename Key , typename Value >
mpqc::Registry< Key, Value >::Registry ( Registry< Key, Value > &&  )
default

◆ ~Registry()

template<typename Key , typename Value >
virtual mpqc::Registry< Key, Value >::~Registry ( )
inlinevirtual

Member Function Documentation

◆ clear()

template<typename Key , typename Value >
virtual void mpqc::Registry< Key, Value >::clear ( )
inlinevirtual

clears the contents of the registry

◆ have()

template<typename Key , typename Value >
bool mpqc::Registry< Key, Value >::have ( const Key &  key) const
inline

check if have key in registry

◆ insert() [1/2]

template<typename Key , typename Value >
void mpqc::Registry< Key, Value >::insert ( const Key &  key,
const Value &  val 
)
inline

insert {Key,Value} pair

Note
val is copied

◆ insert() [2/2]

template<typename Key , typename Value >
void mpqc::Registry< Key, Value >::insert ( const value_type val)
inline

insert to registry by std::pair<Key, Value>, throw error if key already exist

◆ operator=() [1/2]

template<typename Key , typename Value >
Registry& mpqc::Registry< Key, Value >::operator= ( Registry< Key, Value > &&  )
default

◆ operator=() [2/2]

template<typename Key , typename Value >
Registry& mpqc::Registry< Key, Value >::operator= ( Registry< Key, Value > const &  )
default

◆ purge_if()

template<typename Key , typename Value >
template<typename Pred >
void mpqc::Registry< Key, Value >::purge_if ( const Pred &  p)
inline

purges all objects if p(value_type) == true

◆ registry()

template<typename Key , typename Value >
const container_type& mpqc::Registry< Key, Value >::registry ( ) const
inline

return the registry

◆ remove()

template<typename Key , typename Value >
virtual void mpqc::Registry< Key, Value >::remove ( const Key &  key)
inlinevirtual

remove Value by Key

Parameters
[in]keya Key object referring to the item to be removed
Note
does not throw even if the item does not exist

◆ retrieve() [1/2]

template<typename Key , typename Value >
Value& mpqc::Registry< Key, Value >::retrieve ( const Key &  key)
inline

find item by key, return non-const reference to the value

Parameters
keythe item key
Exceptions
ProgrammingErrorif key not found

◆ retrieve() [2/2]

template<typename Key , typename Value >
const Value& mpqc::Registry< Key, Value >::retrieve ( const Key &  key) const
inline

find item by key, return const reference to the value

Parameters
keythe item key
Exceptions
ProgrammingErrorif key not found

◆ retrieve_ptr() [1/2]

template<typename Key , typename Value >
virtual Value* mpqc::Registry< Key, Value >::retrieve_ptr ( const Key &  key)
inlinevirtual

retrieves pointer to an item

Parameters
[in]keya Key object describing the item to be retrieved
Returns
nullptr if the item corresponding to key does not exist, otherwise return pointer

◆ retrieve_ptr() [2/2]

template<typename Key , typename Value >
const Value* mpqc::Registry< Key, Value >::retrieve_ptr ( const Key &  key) const
inline

retrieves pointer to an item

Parameters
[in]keya Key object describing the item to be retrieved
Returns
nullptr if the item corresponding to key does not exist, otherwise return pointer

◆ update() [1/2]

template<typename Key , typename Value >
void mpqc::Registry< Key, Value >::update ( const Key &  key,
const Value &  val 
)
inline

update value which already exists in registry

◆ update() [2/2]

template<typename Key , typename Value >
void mpqc::Registry< Key, Value >::update ( const value_type val)
inline

update value which already exists in registry

Member Data Documentation

◆ registry_

template<typename Key , typename Value >
container_type mpqc::Registry< Key, Value >::registry_
mutableprotected

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