2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __VOM_LLDP_GLOBAL_H__
17 #define __VOM_LLDP_GLOBAL_H__
20 #include "vom/inspect.hpp"
21 #include "vom/object_base.hpp"
23 #include "vom/singular_db.hpp"
27 * A representation of LLDP global configuration
29 class lldp_global : public object_base
33 * The key for the global conifugration is the 'system' namse
35 typedef std::string key_t;
38 * Construct a new object matching the desried state
40 lldp_global(const std::string& system_name,
42 uint32_t tx_interval);
47 lldp_global(const lldp_global& o);
55 * Get this objects key
57 const key_t& key() const;
62 bool operator==(const lldp_global& l) const;
65 * Return the 'singular' of the LLDP global that matches this object
67 std::shared_ptr<lldp_global> singular() const;
70 * convert to string format for debug purposes
72 std::string to_string() const;
75 * Dump all LLDP globals into the stream provided
77 static void dump(std::ostream& os);
80 * Find LLDP global config from its key
82 static std::shared_ptr<lldp_global> find(const key_t& k);
86 * Class definition for listeners to OM events
88 class event_handler : public OM::listener, public inspect::command_handler
92 virtual ~event_handler() = default;
95 * Handle a populate event
97 void handle_populate(const client_db::key_t& key);
100 * Handle a replay event
102 void handle_replay();
105 * Show the object in the Singular DB
107 void show(std::ostream& os);
110 * Get the sortable Id of the listener
112 dependency_t order() const;
116 * event_handler to register with OM
118 static event_handler m_evh;
121 * Enquue commonds to the VPP command Q for the update
123 void update(const lldp_global& obj);
126 * Find or add LLDP global to the OM
128 static std::shared_ptr<lldp_global> find_or_add(const lldp_global& temp);
131 * It's the OM class that calls singular()
136 * It's the singular_db class that calls replay()
138 friend class singular_db<key_t, lldp_global>;
141 * Sweep/reap the object if still stale
146 * replay the object to create it in hardware
153 const std::string m_system_name;
159 uint32_t m_tx_interval;
162 * HW globaluration for the binding. The bool representing the
165 HW::item<bool> m_binding;
168 * A map of all Lldp globals keyed against the system name.
169 * there needs to be some sort of key, that will do.
171 static singular_db<key_t, lldp_global> m_db;
176 * fd.io coding-style-patch-verification: ON
179 * eval: (c-set-style "mozilla")