2 * Copyright (c) 2019 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_QOS_STORE_H__
17 #define __VOM_QOS_STORE_H__
21 #include "vom/interface.hpp"
22 #include "vom/qos_types.hpp"
23 #include "vom/singular_db.hpp"
27 * Types belonging to QoS
31 class store : public object_base
34 store(const interface& i, const source_t& source, bits_t value);
35 store(const store& r);
39 typedef std::pair<interface::key_t, source_t> key_t;
42 * Return the object's key
44 const key_t key() const;
49 bool operator==(const store& bdae) const;
52 * Return the matching 'singular instance'
54 std::shared_ptr<store> singular() const;
57 * Find the instnace of the bridge_domain domain in the OM
59 static std::shared_ptr<store> find(const key_t& k);
62 * Dump all bridge_domain-doamin into the stream provided
64 static void dump(std::ostream& os);
67 * replay the object to create it in hardware
72 * Convert to string for debugging
74 std::string to_string() const;
78 * Class definition for listeners to OM events
80 class event_handler : public OM::listener, public inspect::command_handler
84 virtual ~event_handler() = default;
87 * Handle a populate event
89 void handle_populate(const client_db::key_t& key);
92 * Handle a replay event
97 * Show the object in the Singular DB
99 void show(std::ostream& os);
102 * Get the sortable Id of the listener
104 dependency_t order() const;
108 * event_handler to register with OM
110 static event_handler m_evh;
113 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
115 void update(const store& obj);
118 * Find or add the instnace of the bridge_domain domain in the OM
120 static std::shared_ptr<store> find_or_add(const store& temp);
123 * It's the VPPHW class that updates the objects in HW
125 friend class VOM::OM;
128 * It's the singular_db class that calls replay()
130 friend class singular_db<key_t, store>;
133 * Sweep/reap the object if still stale
138 * HW configuration for the config. The bool representing the
139 * do/don't configured/unconfigured.
141 HW::item<bool> m_config;
144 * The interface the endpoint is attached to.
146 std::shared_ptr<interface> m_itf;
149 * QoS source to store from
154 * QoS Value to store in the buffer
159 * A map of all bridge_domains
161 static singular_db<key_t, store> m_db;
166 std::ostream& operator<<(std::ostream& os, const QoS::store::key_t& key);
171 * fd.io coding-style-patch-verification: ON
174 * eval: (c-set-style "mozilla")