X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fvom%2Fl3_binding.cpp;h=13bc1ffd575f8cf5f6ca576dfbcc9e3023d9184c;hb=756cd9441752fc8f84104c9ee19099506ba89f85;hp=8f90d45eec4443a0ee02fff178a5b5c5b44ff283;hpb=352ea0c4931b54012ce8d55634e3dd3f6ee6802b;p=vpp.git diff --git a/src/vpp-api/vom/l3_binding.cpp b/src/vpp-api/vom/l3_binding.cpp index 8f90d45eec4..13bc1ffd575 100644 --- a/src/vpp-api/vom/l3_binding.cpp +++ b/src/vpp-api/vom/l3_binding.cpp @@ -15,9 +15,10 @@ #include "vom/l3_binding.hpp" #include "vom/l3_binding_cmds.hpp" +#include "vom/singular_db_funcs.hpp" namespace VOM { -singular_db l3_binding::m_db; +singular_db l3_binding::m_db; l3_binding::event_handler l3_binding::m_evh; @@ -27,14 +28,14 @@ l3_binding::event_handler l3_binding::m_evh; l3_binding::l3_binding(const interface& itf, const route::prefix_t& pfx) : m_itf(itf.singular()) , m_pfx(pfx) - , m_binding(true) + , m_binding(true, rc_t::NOOP) { } l3_binding::l3_binding(const l3_binding& o) : m_itf(o.m_itf) , m_pfx(o.m_pfx) - , m_binding(true) + , m_binding(o.m_binding) { } @@ -43,7 +44,19 @@ l3_binding::~l3_binding() sweep(); // not in the DB anymore. - m_db.release(make_pair(m_itf->key(), m_pfx), this); + m_db.release(key(), this); +} + +bool +l3_binding::operator==(const l3_binding& l) const +{ + return ((m_pfx == l.m_pfx) && (*m_itf == *l.m_itf)); +} + +const l3_binding::key_t +l3_binding::key() const +{ + return (make_pair(m_itf->key(), m_pfx)); } void @@ -80,20 +93,20 @@ l3_binding::itf() const l3_binding::const_iterator_t l3_binding::cbegin() { - return m_db.cbegin(); + return m_db.begin(); } l3_binding::const_iterator_t l3_binding::cend() { - return m_db.cend(); + return m_db.end(); } std::string l3_binding::to_string() const { std::ostringstream s; - s << "L3-config:[" << m_itf->to_string() << " prefix:" << m_pfx.to_string() + s << "L3-binding:[" << m_itf->to_string() << " prefix:" << m_pfx.to_string() << " " << m_binding.to_string() << "]"; return (s.str()); @@ -116,7 +129,13 @@ l3_binding::update(const l3_binding& desired) std::shared_ptr l3_binding::find_or_add(const l3_binding& temp) { - return (m_db.find_or_add(make_pair(temp.m_itf->key(), temp.m_pfx), temp)); + return (m_db.find_or_add(temp.key(), temp)); +} + +std::shared_ptr +l3_binding::find(const key_t& k) +{ + return (m_db.find(k)); } std::shared_ptr @@ -128,11 +147,11 @@ l3_binding::singular() const void l3_binding::dump(std::ostream& os) { - m_db.dump(os); + db_dump(m_db, os); } std::ostream& -operator<<(std::ostream& os, const l3_binding::key_type_t& key) +operator<<(std::ostream& os, const l3_binding::key_t& key) { os << "[" << key.first << ", " << key.second << "]"; @@ -149,13 +168,13 @@ l3_binding::find(const interface& i) */ std::deque> l3s; - auto it = m_db.cbegin(); + auto it = m_db.begin(); - while (it != m_db.cend()) { + while (it != m_db.end()) { /* - * The key in the DB is a pair of the interface's name and prefix. - * If the keys match, save the L3-config - */ + * The key in the DB is a pair of the interface's name and prefix. + * If the keys match, save the L3-config + */ auto key = it->first; if (i.key() == key.first) { @@ -184,8 +203,8 @@ void l3_binding::event_handler::handle_populate(const client_db::key_t& key) { /** - * This is done while populating the interfaces - */ + * This is done while populating the interfaces + */ } dependency_t @@ -197,7 +216,7 @@ l3_binding::event_handler::order() const void l3_binding::event_handler::show(std::ostream& os) { - m_db.dump(os); + db_dump(m_db, os); } }