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.
18 #include "vom/logger.hpp"
24 std::unique_ptr<OM::listener_list> OM::m_listeners;
27 * Initialse the connection to VPP
32 m_db = new client_db();
36 OM::mark(const client_db::key_t& key)
39 * Find if the object already stored on behalf of this key.
42 object_ref_list& objs = m_db->find(key);
44 auto mark_obj = [](const object_ref& oref) { oref.mark(); };
46 std::for_each(objs.begin(), objs.end(), mark_obj);
50 OM::sweep(const client_db::key_t& key)
53 * Find if the object already stored on behalf of this key.
56 object_ref_list& objs = m_db->find(key);
58 for (auto it = objs.begin(); it != objs.end();) {
70 OM::remove(const client_db::key_t& key)
73 * Simply reset the list for this key. This will desctruct the
74 * object list and shared_ptrs therein. When the last shared_ptr
75 * goes the objects desctructor is called and the object is
86 VOM_LOG(log_level_t::INFO) << "replay";
88 * the listeners are sorted in dependency order
90 for (listener* l : *m_listeners) {
97 OM::dump(const client_db::key_t& key, std::ostream& os)
103 OM::dump(std::ostream& os)
109 OM::populate(const client_db::key_t& key)
111 VOM_LOG(log_level_t::INFO) << "populate";
114 * the listeners are sorted in dependency order
116 for (listener* l : *m_listeners) {
117 l->handle_populate(key);
121 * once we have it all, mark it stale.
127 OM::register_listener(OM::listener* listener)
130 m_listeners.reset(new listener_list);
133 m_listeners->insert(listener);
138 OM::mark_n_sweep::mark_n_sweep(const client_db::key_t& key)
144 OM::mark_n_sweep::~mark_n_sweep()
151 * fd.io coding-style-patch-verification: ON
154 * eval: (c-set-style "mozilla")