diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2017-11-23 12:15:00 -0800 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2017-11-24 14:04:48 +0000 |
commit | fd920609819a5b10d3d7c8d34fe4fa4214c7da22 (patch) | |
tree | fb0b5c3b5a9ba56308ef704ef922e959aafad17f /src/vpp-api/vom/l3_binding.hpp | |
parent | 227bf211ab65e7aed6862fc881cc949c342200fd (diff) |
VOM: Additions to allow uses to UT applications that use VOM
- find object by key
- compare objects
Change-Id: I36ec8612be9482bcef7ceced2a59f7403f77b3e8
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vpp-api/vom/l3_binding.hpp')
-rw-r--r-- | src/vpp-api/vom/l3_binding.hpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/vpp-api/vom/l3_binding.hpp b/src/vpp-api/vom/l3_binding.hpp index a1470587e94..0177e56ea2b 100644 --- a/src/vpp-api/vom/l3_binding.hpp +++ b/src/vpp-api/vom/l3_binding.hpp @@ -31,6 +31,11 @@ class l3_binding : public object_base { public: /** + * The key type for l3_bindings + */ + typedef std::pair<interface::key_t, route::prefix_t> key_t; + + /** * Construct a new object matching the desried state */ l3_binding(const interface& itf, const route::prefix_t& pfx); @@ -46,14 +51,19 @@ public: ~l3_binding(); /** - * The key type for l3_bindings + * Comparison operator */ - typedef std::pair<interface::key_type, route::prefix_t> key_type_t; + bool operator==(const l3_binding& l) const; + + /** + * Get the object's key + */ + const key_t key() const; /** * The iterator type */ - typedef singular_db<key_type_t, l3_binding>::const_iterator const_iterator_t; + typedef singular_db<key_t, l3_binding>::const_iterator const_iterator_t; static const_iterator_t cbegin(); static const_iterator_t cend(); @@ -85,10 +95,15 @@ public: static void dump(std::ostream& os); /** - * Find an singular instance in the DB for the interface passed + * Find all bindings in the DB for the interface passed */ static std::deque<std::shared_ptr<l3_binding>> find(const interface& i); + /** + * Find a binding from its key + */ + static std::shared_ptr<l3_binding> find(const key_t& k); + private: /** * Class definition for listeners to OM events @@ -143,7 +158,7 @@ private: /** e* It's the singular_db class that calls replay() */ - friend class singular_db<key_type_t, l3_binding>; + friend class singular_db<key_t, l3_binding>; /** * Sweep/reap the object if still stale @@ -179,13 +194,13 @@ private: * A map of all L3 configs keyed against a combination of the interface * and subnet's keys. */ - static singular_db<key_type_t, l3_binding> m_db; + static singular_db<key_t, l3_binding> m_db; }; /** * Ostream output for the key */ -std::ostream& operator<<(std::ostream& os, const l3_binding::key_type_t& key); +std::ostream& operator<<(std::ostream& os, const l3_binding::key_t& key); }; /* |