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 #include "vom/gbp_global.hpp"
17 #include "vom/gbp_global_cmds.hpp"
18 #include "vom/singular_db_funcs.hpp"
22 * A DB of all GBP configs
24 singular_db<std::string, gbp_global> gbp_global::m_db;
26 gbp_global::event_handler gbp_global::m_evh;
28 gbp_global::gbp_global(const std::string& system_name,
29 uint32_t remote_ep_retention)
30 : m_system_name(system_name)
31 , m_remote_ep_retention(remote_ep_retention)
35 gbp_global::gbp_global(const gbp_global& o)
36 : m_system_name(o.m_system_name)
37 , m_remote_ep_retention(o.m_remote_ep_retention)
41 gbp_global::~gbp_global()
44 m_db.release(m_system_name, this);
47 const gbp_global::key_t&
48 gbp_global::key() const
50 return (m_system_name);
54 gbp_global::operator==(const gbp_global& l) const
56 return ((key() == l.key()) &&
57 (m_remote_ep_retention == l.m_remote_ep_retention));
63 // no means to remove this in VPP
67 gbp_global::dump(std::ostream& os)
77 new gbp_global_cmds::config_cmd(m_binding, m_remote_ep_retention));
82 gbp_global::to_string() const
86 << " remote-EP-retention:" << m_remote_ep_retention;
92 gbp_global::update(const gbp_global& desired)
96 new gbp_global_cmds::config_cmd(m_binding, m_remote_ep_retention));
100 std::shared_ptr<gbp_global>
101 gbp_global::find_or_add(const gbp_global& temp)
103 return (m_db.find_or_add(temp.key(), temp));
106 std::shared_ptr<gbp_global>
107 gbp_global::find(const key_t& k)
109 return (m_db.find(k));
112 std::shared_ptr<gbp_global>
113 gbp_global::singular() const
115 return find_or_add(*this);
118 gbp_global::event_handler::event_handler()
120 OM::register_listener(this);
121 inspect::register_handler({ "gbp-global" }, "GBP global configurations",
126 gbp_global::event_handler::handle_replay()
132 gbp_global::event_handler::handle_populate(const client_db::key_t& key)
137 gbp_global::event_handler::order() const
139 return (dependency_t::GLOBAL);
143 gbp_global::event_handler::show(std::ostream& os)
150 * fd.io coding-style-patch-verification: ON
153 * eval: (c-set-style "mozilla")