FD.io VPP  v20.05.1-6-gf53edbc3b
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 begin () const
 Get iterator to the beginning of the DB. More...
 
const_iterator end () const
 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 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 33 of file singular_db.hpp.

Member Typedef Documentation

◆ const_iterator

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 45 of file singular_db.hpp.

Constructor & Destructor Documentation

◆ singular_db()

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

Constructor.

Definition at line 39 of file singular_db.hpp.

Member Function Documentation

◆ add()

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 120 of file singular_db.hpp.

◆ begin()

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

Get iterator to the beginning of the DB.

Definition at line 50 of file singular_db.hpp.

◆ end()

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

Get iterator to the beginning of the DB.

Definition at line 55 of file singular_db.hpp.

◆ find()

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 84 of file singular_db.hpp.

◆ find_or_add()

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 65 of file singular_db.hpp.

◆ release()

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 100 of file singular_db.hpp.

◆ replay()

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 125 of file singular_db.hpp.


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