FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
object_base.cpp
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #include "vom/object_base.hpp"
17 
18 namespace VOM {
19 object_ref::object_ref(std::shared_ptr<object_base> obj)
20  : m_obj(obj)
21  , m_state(OBJECT_STATE_NONE)
22 {
23 }
24 
25 bool
26 object_ref::operator<(const object_ref& other) const
27 {
28  return (m_obj.get() < other.m_obj.get());
29 }
30 
31 std::shared_ptr<object_base>
33 {
34  return (m_obj);
35 }
36 
37 void
39 {
40  m_state = OBJECT_STATE_STALE;
41 }
42 
43 void
45 {
46  m_state = OBJECT_STATE_NONE;
47 }
48 
49 bool
51 {
52  return (m_state == OBJECT_STATE_STALE);
53 }
54 
55 std::ostream&
56 operator<<(std::ostream& os, const object_base& o)
57 {
58  os << o.to_string();
59 
60  return (os);
61 }
62 }
63 
64 /*
65  * fd.io coding-style-patch-verification: OFF
66  *
67  * Local Variables:
68  * eval: (c-set-style "mozilla")
69  * End:
70  */
VOM::object_ref::obj
std::shared_ptr< object_base > obj() const
Return the shared pointer.
Definition: object_base.cpp:32
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::OBJECT_STATE_STALE
@ OBJECT_STATE_STALE
indicates the object is stale.
Definition: object_base.hpp:78
VOM::object_ref::clear
void clear() const
Clear the stale flag on the object.
Definition: object_base.cpp:44
VOM::object_ref::mark
void mark() const
Mark the reference object as stale.
Definition: object_base.cpp:38
VOM::object_ref
A represenation of a reference to a VPP object.
Definition: object_base.hpp:86
VOM::object_ref::object_ref
object_ref(std::shared_ptr< object_base > obj)
Constructor.
Definition: object_base.cpp:19
VOM::OBJECT_STATE_NONE
@ OBJECT_STATE_NONE
Definition: object_base.hpp:70
VOM::operator<<
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
Definition: acl_binding.cpp:201
VOM::object_ref::operator<
bool operator<(const object_ref &other) const
less than operator
Definition: object_base.cpp:26
VOM::object_base::to_string
virtual std::string to_string() const =0
convert to string format for debug purposes
VOM::object_ref::stale
bool stale() const
Query if the object is stale.
Definition: object_base.cpp:50
VOM::object_base
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
object_base.hpp