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_MAP_H__
17 #define __VOM_QOS_MAP_H__
21 #include "vom/interface.hpp"
22 #include "vom/qos_types.hpp"
23 #include "vom/singular_db.hpp"
27 * Types belonging to QoS
32 * A QoS map determines how value from one source are translated to
33 * values of another source
35 class map : public object_base
38 typedef std::array<std::array<bits_t, 256>, 4> outputs_t;
40 map(uint32_t id, const outputs_t& o);
45 typedef uint32_t key_t;
48 * Return the object's key
50 const key_t key() const;
53 * Return the object's ID
55 const key_t id() const;
60 bool operator==(const map& bdae) const;
63 * Return the matching 'singular instance'
65 std::shared_ptr<map> singular() const;
68 * Find the instnace of the bridge_domain domain in the OM
70 static std::shared_ptr<map> find(const key_t& k);
73 * Dump all bridge_domain-doamin into the stream provided
75 static void dump(std::ostream& os);
78 * replay the object to create it in hardware
83 * Convert to string for debugging
85 std::string to_string() const;
89 * Class definition for listeners to OM events
91 class event_handler : public OM::listener, public inspect::command_handler
95 virtual ~event_handler() = default;
98 * Handle a populate event
100 void handle_populate(const client_db::key_t& key);
103 * Handle a replay event
105 void handle_replay();
108 * Show the object in the Singular DB
110 void show(std::ostream& os);
113 * Get the sortable Id of the listener
115 dependency_t order() const;
119 * event_handler to register with OM
121 static event_handler m_evh;
124 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
126 void update(const map& obj);
129 * Find or add the instnace of the bridge_domain domain in the OM
131 static std::shared_ptr<map> find_or_add(const map& temp);
134 * It's the VPPHW class that updates the objects in HW
136 friend class VOM::OM;
139 * It's the singular_db class that calls replay()
141 friend class singular_db<key_t, map>;
144 * Sweep/reap the object if still stale
149 * HW configuration for the config. The bool representing the
150 * do/don't configured/unconfigured.
152 HW::item<bool> m_config;
155 * unique ID of the MAP.
160 * outputs from the translation
165 * A map of all bridge_domains
167 static singular_db<key_t, map> m_db;
175 * fd.io coding-style-patch-verification: ON
178 * eval: (c-set-style "mozilla")