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_OBJECT_H__
17 #define __VOM_OBJECT_H__
22 #include "vom/types.hpp"
26 * A base class for all object_base in the VPP object_base-Model.
27 * provides the abstract interface.
33 * convert to string format for debug purposes
35 virtual std::string to_string() const = 0;
38 * Sweep/reap the object if still stale
40 virtual void sweep(void) = 0;
43 * replay the object to create it in hardware
45 virtual void replay(void) = 0;
49 * Constructable by derived classes only
51 object_base() = default;
55 virtual ~object_base() = default;
59 * note we are not maintaining dependencies back to the
60 * keys. i.e. this object does not know all the keys that
70 OBJECT_STATE_NONE = 0,
72 * indicates the object is stale. This flag is set
73 * when a new epoch is declared. the flag is cleared
74 * when the object is updated in the new epoch. If the
75 * flag is still set after convergence is declared then
76 * the object is deleted
82 * A represenation of a reference to a VPP object.
83 * the reference counting is held through the use of shared pointers.
84 * We also maintain the state of the object ready for mark n' sweep.
92 object_ref(std::shared_ptr<object_base> obj);
97 bool operator<(const object_ref& other) const;
100 * Return the shared pointer
102 std::shared_ptr<object_base> obj() const;
105 * Mark the reference object as stale
110 * Clear the stale flag on the object
115 * Query if the object is stale
121 * The reference object
123 std::shared_ptr<object_base> m_obj;
126 * Not part of the key (in the set) so we can change it
129 mutable obj_state_t m_state;
133 * ostream print of a VPP Obect
135 std::ostream& operator<<(std::ostream& os, const object_base& o);
139 * fd.io coding-style-patch-verification: ON
142 * eval: (c-set-style "mozilla")