X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fvom%2Facl_list.hpp;h=eff5e1c5a521913631c3e93564b3eaf81fc03a57;hb=756cd9441752fc8f84104c9ee19099506ba89f85;hp=ff3eeeb21b226b3b2850c914df6c9d5dbfd006da;hpb=810bea18065c2477ed561ed7d835aaf4221c5749;p=vpp.git diff --git a/src/vpp-api/vom/acl_list.hpp b/src/vpp-api/vom/acl_list.hpp index ff3eeeb21b2..eff5e1c5a52 100644 --- a/src/vpp-api/vom/acl_list.hpp +++ b/src/vpp-api/vom/acl_list.hpp @@ -53,7 +53,8 @@ public: * Construct a new object matching the desried state */ list(const key_t& key) - : m_key(key) + : m_hdl(handle_t::INVALID) + , m_key(key) { } @@ -64,10 +65,10 @@ public: } list(const key_t& key, const rules_t& rules) - : m_key(key) + : m_hdl(handle_t::INVALID) + , m_key(key) , m_rules(rules) { - m_evh.order(); } /** @@ -129,7 +130,7 @@ public: /** * Return the VPP assign handle */ - const handle_t& handle() const { return m_hdl.data(); } + const handle_t& handle() const { return (singular()->handle_i()); } static std::shared_ptr find(const handle_t& handle) { @@ -141,12 +142,19 @@ public: return (m_db.find(key)); } - static void add(const handle_t& handle, std::shared_ptr sp) + static void add(const key_t& key, const HW::item& item) { - m_hdl_db[handle] = sp; + std::shared_ptr sp = find(key); + + if (sp && item) { + m_hdl_db[item.data()] = sp; + } } - static void remove(const handle_t& handle) { m_hdl_db.erase(handle); } + static void remove(const HW::item& item) + { + m_hdl_db.erase(item.data()); + } const key_t& key() const { return m_key; } @@ -167,11 +175,8 @@ private: class event_handler : public OM::listener, public inspect::command_handler { public: - event_handler() - { - OM::register_listener(this); - inspect::register_handler({ "acl" }, "ACL lists", this); - } + event_handler(); + virtual ~event_handler() = default; /** @@ -187,7 +192,7 @@ private: /** * Show the object in the Singular DB */ - void show(std::ostream& os) { m_db.dump(os); } + void show(std::ostream& os); /** * Get the sortable Id of the listener @@ -215,9 +220,14 @@ private: */ static std::shared_ptr find_or_add(const list& temp) { - return (m_db.find_or_add(temp.m_key, temp)); + return (m_db.find_or_add(temp.key(), temp)); } + /** + * return the acl-list's handle in the singular instance + */ + const handle_t& handle_i() const { return (m_hdl.data()); } + /* * It's the VOM::OM class that updates call update */ @@ -246,7 +256,7 @@ private: /** * A map of all ACLs keyed against VPP's handle */ - static std::map> m_hdl_db; + static std::map> m_hdl_db; /** * The Key is a user defined identifer for this ACL @@ -279,7 +289,7 @@ singular_db::key_t, ACL::list> list::m_db; * Definition of the static per-handle DB for ACL Lists */ template -std::map>> list::m_hdl_db; +std::map>> list::m_hdl_db; template typename ACL::list::event_handler list::m_evh;