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_GBP_GLOBAL_H__
17 #define __VOM_GBP_GLOBAL_H__
20 #include "vom/inspect.hpp"
21 #include "vom/object_base.hpp"
23 #include "vom/singular_db.hpp"
27 * A representation of GBP global configuration
29 class gbp_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 gbp_global(const std::string& system_name, uint32_t remote_ep_retention);
45 gbp_global(const gbp_global& o);
53 * Get this objects key
55 const key_t& key() const;
60 bool operator==(const gbp_global& l) const;
63 * Return the 'singular' of the GBP global that matches this object
65 std::shared_ptr<gbp_global> singular() const;
68 * convert to string format for debug purposes
70 std::string to_string() const;
73 * Dump all GBP globals into the stream provided
75 static void dump(std::ostream& os);
78 * Find GBP global config from its key
80 static std::shared_ptr<gbp_global> find(const key_t& k);
84 * Class definition for listeners to OM events
86 class event_handler : public OM::listener, public inspect::command_handler
90 virtual ~event_handler() = default;
93 * Handle a populate event
95 void handle_populate(const client_db::key_t& key);
98 * Handle a replay event
100 void handle_replay();
103 * Show the object in the Singular DB
105 void show(std::ostream& os);
108 * Get the sortable Id of the listener
110 dependency_t order() const;
114 * event_handler to register with OM
116 static event_handler m_evh;
119 * Enquue commonds to the VPP command Q for the update
121 void update(const gbp_global& obj);
124 * Find or add GBP global to the OM
126 static std::shared_ptr<gbp_global> find_or_add(const gbp_global& temp);
129 * It's the OM class that calls singular()
134 * It's the singular_db class that calls replay()
136 friend class singular_db<key_t, gbp_global>;
139 * Sweep/reap the object if still stale
144 * replay the object to create it in hardware
151 const std::string m_system_name;
156 uint32_t m_remote_ep_retention;
159 * HW globaluration for the binding. The bool representing the
162 HW::item<bool> m_binding;
165 * A map of all Gbp globals keyed against the system name.
166 * there needs to be some sort of key, that will do.
168 static singular_db<key_t, gbp_global> m_db;
173 * fd.io coding-style-patch-verification: ON
176 * eval: (c-set-style "mozilla")