MPQC  3.0.0-alpha
sc::Registry< Key, Value, CreationPolicy, KeyEqual, ValueEqual > Class Template Reference

Registry wraps std::map and can be policy-configured to act as a Singleton or a regular object. More...

#include <util/misc/registry.h>

Inheritance diagram for sc::Registry< Key, Value, CreationPolicy, KeyEqual, ValueEqual >:
sc::RefCount

Classes

class  not_found
 

Public Member Functions

void clear ()
 erases all entries
 
void remove (const Key &key)
 removes the object corresponding to key
 
template<typename Pred >
void remove_if (const Pred &p)
 removes all objects whose keys evaluate predicate to true: p(key) == true
 
bool key_exists (const Key &key) const
 key exists?
 
bool value_exists (const Value &value) const
 value exists?
 
const Value & value (const Key &key) const
 returns object that corresponds to this key. If key is not known, throws
 
const Key & key (const Value &obj) const
 returns key that corresponds to this object. If obj is not known, throws
 
void add (const Key &key, const Value &obj)
 registers this object
 
void add (const std::pair< Key, Value > &keyval_pair)
 a useful variation of Registry::add(const Key&, const Value&)
 
void print (std::ostream &os=ExEnv::out0()) const
 
- Public Member Functions inherited from sc::RefCount
size_t identifier () const
 Return the unique identifier for this object that can be compared for different objects of different types. More...
 
int lock_ptr () const
 Lock this object.
 
int unlock_ptr () const
 Unlock this object.
 
void use_locks (bool inVal)
 start and stop using locks on this object
 
refcount_t nreference () const
 Return the reference count.
 
refcount_t reference ()
 Increment the reference count and return the new count.
 
refcount_t dereference ()
 Decrement the reference count and return the new count.
 
int managed () const
 
void unmanage ()
 Turn off the reference counting mechanism for this object. More...
 

Static Public Member Functions

static Ref< Registryinstance ()
 
static void save_instance (const Ref< Registry > &, StateOut &)
 
static Ref< Registryrestore_instance (StateIn &)
 

Friends

class CreationPolicy< Registry< Key, Value, CreationPolicy, KeyEqual, ValueEqual > >
 

Additional Inherited Members

- Protected Member Functions inherited from sc::RefCount
 RefCount (const RefCount &)
 
RefCountoperator= (const RefCount &)
 

Detailed Description

template<typename Key, typename Value, template< typename > class CreationPolicy, typename KeyEqual = std::equal_to<Key>, typename ValueEqual = std::equal_to<Value>>
class sc::Registry< Key, Value, CreationPolicy, KeyEqual, ValueEqual >

Registry wraps std::map and can be policy-configured to act as a Singleton or a regular object.

Registry is not a SavableState, but it can be serialized (see save_instance and restore_instance methods). Therefore both Key and Value are assumed to be serializable with StateIn and StateOut.

KeyEqual and ValueEqual are Functor types that define the equivalence of two Key (or Value) objects. By default std::equal_to is used. For pointer types std::equal_to may not be appropriate since it will not distinguish 2 equivalent but distinct objects.

See also
sc::detail::SingletonCreationPolicy
sc::detail::NonsingletonCreationPolicy

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

Generated at Sun Jan 26 2020 23:24:11 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.