|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
16 #ifndef __VOM_INST_DB_H__
17 #define __VOM_INST_DB_H__
32 template <
typename KEY,
typename OBJ>
64 template <
typename DERIVED>
67 auto search = m_map.find(
key);
69 if (search == m_map.end()) {
70 std::shared_ptr<OBJ> sp = std::make_shared<DERIVED>(obj);
78 return (search->second.lock());
86 auto search = m_map.find(
key);
88 if (search == m_map.end()) {
89 std::shared_ptr<OBJ> sp(NULL);
94 return (search->second.lock());
102 auto search = m_map.find(
key);
104 if (search != m_map.end()) {
105 if (search->second.expired()) {
108 std::shared_ptr<OBJ> sp = m_map[
key].lock();
110 if (sp.get() == obj) {
120 void add(
const KEY&
key, std::shared_ptr<OBJ> sp) { m_map[
key] = sp; }
127 for (
auto entry : m_map) {
128 entry.second.lock()->replay();
136 std::map<const KEY, std::weak_ptr<OBJ>> m_map;
The VPP Object Model (VOM) library.
std::map< arp_proxy_config::key_t, std::weak_ptr< VOM::arp_proxy_config > >::const_iterator const_iterator
Iterator.
singular_db()
Constructor.
void release(const KEY &key, const OBJ *obj)
Release the object from the DB store, if it's the one we have stored.
const_iterator end() const
Get iterator to the beginning of the DB.
const static log_level_t DEBUG
void replay()
Populate VPP from current state, on VPP restart.
std::shared_ptr< OBJ > find_or_add(const KEY &key, const DERIVED &obj)
Find or add the object to the store.
void add(const KEY &key, std::shared_ptr< OBJ > sp)
Find the object to the store.
A Database to store the unique 'singular' instances of a single object type.
std::shared_ptr< OBJ > find(const KEY &key)
Find the object to the store.
const_iterator begin() const
Get iterator to the beginning of the DB.