FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
VOM::singular_db< KEY, OBJ > Class Template Reference

A Database to store the unique 'singular' instances of a single object type. More...

Public Types

typedef std::map< KEY, std::weak_ptr< OBJ > >::const_iterator const_iterator
 Iterator. More...
 

Public Member Functions

 singular_db ()
 Constructor. More...
 
const_iterator cbegin ()
 Get iterator to the beginning of the DB. More...
 
const_iterator cend ()
 Get iterator to the beginning of the DB. More...
 
template<typename DERIVED >
std::shared_ptr< OBJ > find_or_add (const KEY &key, const DERIVED &obj)
 Find or add the object to the store. More...
 
std::shared_ptr< OBJ > find (const KEY &key)
 Find the object to the store. More...
 
void release (const KEY &key, const OBJ *obj)
 Release the object from the DB store, if it's the one we have stored. More...
 
void add (const KEY &key, std::shared_ptr< OBJ > sp)
 Find the object to the store. More...
 
void dump (std::ostream &os)
 Print each of the object in the DB into the stream provided. More...
 
void replay ()
 Populate VPP from current state, on VPP restart. More...
 

Detailed Description

template<typename KEY, typename OBJ>
class VOM::singular_db< KEY, OBJ >

A Database to store the unique 'singular' instances of a single object type.

The instances are stored as weak pointers. So the DB does not own these objects, they are owned by object in the client_db.

Definition at line 32 of file singular_db.hpp.

Member Typedef Documentation

template<typename KEY, typename OBJ>
typedef std::map<KEY, std::weak_ptr<OBJ> >::const_iterator VOM::singular_db< KEY, OBJ >::const_iterator

Iterator.

Definition at line 44 of file singular_db.hpp.

Constructor & Destructor Documentation

template<typename KEY, typename OBJ>
VOM::singular_db< KEY, OBJ >::singular_db ( )
inline

Constructor.

Definition at line 38 of file singular_db.hpp.

Member Function Documentation

template<typename KEY, typename OBJ>
void VOM::singular_db< KEY, OBJ >::add ( const KEY &  key,
std::shared_ptr< OBJ >  sp 
)
inline

Find the object to the store.

Definition at line 119 of file singular_db.hpp.

template<typename KEY, typename OBJ>
const_iterator VOM::singular_db< KEY, OBJ >::cbegin ( )
inline

Get iterator to the beginning of the DB.

Definition at line 49 of file singular_db.hpp.

template<typename KEY, typename OBJ>
const_iterator VOM::singular_db< KEY, OBJ >::cend ( )
inline

Get iterator to the beginning of the DB.

Definition at line 54 of file singular_db.hpp.

template<typename KEY, typename OBJ>
void VOM::singular_db< KEY, OBJ >::dump ( std::ostream &  os)
inline

Print each of the object in the DB into the stream provided.

Definition at line 124 of file singular_db.hpp.

template<typename KEY, typename OBJ>
std::shared_ptr<OBJ> VOM::singular_db< KEY, OBJ >::find ( const KEY &  key)
inline

Find the object to the store.

Definition at line 83 of file singular_db.hpp.

template<typename KEY, typename OBJ>
template<typename DERIVED >
std::shared_ptr<OBJ> VOM::singular_db< KEY, OBJ >::find_or_add ( const KEY &  key,
const DERIVED &  obj 
)
inline

Find or add the object to the store.

The object passed is deisred state. A new instance will be copy constructed from it. This function is templatised on the object type passed, which may be drrived from, the object type stored. this prevents slicing during the make_shared construction.

Definition at line 64 of file singular_db.hpp.

template<typename KEY, typename OBJ>
void VOM::singular_db< KEY, OBJ >::release ( const KEY &  key,
const OBJ *  obj 
)
inline

Release the object from the DB store, if it's the one we have stored.

Definition at line 99 of file singular_db.hpp.

template<typename KEY, typename OBJ>
void VOM::singular_db< KEY, OBJ >::replay ( void  )
inline

Populate VPP from current state, on VPP restart.

Definition at line 135 of file singular_db.hpp.


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