A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
attribute-iterator.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
5 */
6
7#ifndef ATTRIBUTE_ITERATOR_H
8#define ATTRIBUTE_ITERATOR_H
9
10#include "ns3/object-ptr-container.h"
11#include "ns3/object.h"
12#include "ns3/ptr.h"
13
14#include <vector>
15
16namespace ns3
17{
18
19/**
20 * \ingroup configstore
21 *
22 * \brief Iterator to iterate on the values of attributes of an ns3::Object
23 * \note This class is used internally by ConfigStore and GtkConfigStore.
24 */
26{
27 public:
29 virtual ~AttributeIterator();
30
31 /**
32 * Start the process of iterating all objects from the root namespace object
33 */
34 void Iterate();
35
36 protected:
37 /**
38 * Get the current attribute path
39 * \returns the current path string
40 */
41 std::string GetCurrentPath() const;
42
43 private:
44 /**
45 * This method visits and performs a config-store action (such as saving
46 * to a text file) on the attribute values corresponding to the input
47 * object pointer and attribute name.
48 *
49 * \param object the object visited
50 * \param name the attribute name
51 */
52 virtual void DoVisitAttribute(Ptr<Object> object, std::string name) = 0;
53 /**
54 * This method is called to start the process of visiting the input object
55 * \param object the object visited
56 */
57 virtual void DoStartVisitObject(Ptr<Object> object);
58 /**
59 * This method is called to end the process of visiting the currently
60 * visited object.
61 */
62 virtual void DoEndVisitObject();
63 /**
64 * Visit the attribute of type ns3::PointerValue, with the provided name,
65 * found on the object pointed to by the first argument.
66 *
67 * \param object the object on which the attribute of type PointerValue resides
68 * \param name the attribute name provided
69 * \param [in] value Ptr to the ns3::Object pointed to by the attribute
70 */
71 virtual void DoStartVisitPointerAttribute(Ptr<Object> object,
72 std::string name,
73 Ptr<Object> value);
74 /**
75 * End the visit to the attribute of type ns3::PointerValue.
76 */
77 virtual void DoEndVisitPointerAttribute();
78 /**
79 * Visit the attribute of type ns3::ObjectVectorValue, with the
80 * provided name, found on the object pointed to by the first argument.
81 *
82 * \note type name ObjectVectorValue is an alias for ObjectPtrContainerValue
83 *
84 * \param object the object on which the attribute of type ObjectVectorValue resides
85 * \param name the attribute name provided
86 * \param [in] vector the ObjectPtrContainerValue corresponding to the named attribute
87 */
88 virtual void DoStartVisitArrayAttribute(Ptr<Object> object,
89 std::string name,
90 const ObjectPtrContainerValue& vector);
91 /**
92 * End the visit to the attribute of type ns3::ObjectVectorValue.
93 */
94 virtual void DoEndVisitArrayAttribute();
95 /**
96 * Start to visit the object found in the input array at the provided index
97 * \param vector the array
98 * \param index the index into the array
99 * \param [in] item the array item to visit
100 */
101 virtual void DoStartVisitArrayItem(const ObjectPtrContainerValue& vector,
102 uint32_t index,
103 Ptr<Object> item);
104 /**
105 * End the visit to the array item
106 */
107 virtual void DoEndVisitArrayItem();
108
109 /**
110 * Perform the iteration
111 * \param object the object visited
112 */
113 void DoIterate(Ptr<Object> object);
114 /**
115 * Check if this object has already been examined
116 * \param object the object to check
117 * \returns true if object has been examined
118 */
119 bool IsExamined(Ptr<const Object> object);
120 /**
121 * Get current attribute path
122 * \param attr the current attribute string
123 * \returns the current path string
124 */
125 std::string GetCurrentPath(std::string attr) const;
126
127 /**
128 * Visit attribute to perform a config store operation on it
129 * \param object the current object
130 * \param name the attribute name
131 */
132 void VisitAttribute(Ptr<Object> object, std::string name);
133 /**
134 * Start to visit an object to visit its attributes
135 * \param object the current object
136 */
137 void StartVisitObject(Ptr<Object> object);
138 /**
139 * End the visit to the object
140 */
141 void EndVisitObject();
142 /**
143 * Visit the attribute of type ns3::PointerValue, with the provided name,
144 * found on the object pointed to by the first argument.
145 *
146 * \param object the object on which the attribute of type PointerValue resides
147 * \param name the attribute name provided
148 * \param [in] value Ptr to the ns3::Object pointed to by the attribute
149 */
150 void StartVisitPointerAttribute(Ptr<Object> object, std::string name, Ptr<Object> value);
151 /**
152 * End the visit to the attribute of type ns3::PointerValue.
153 */
155 /**
156 * Visit the attribute of type ns3::ObjectVectorValue, with the
157 * provided name, found on the object pointed to by the first argument.
158 *
159 * \note type name ObjectVectorValue is an alias for ObjectPtrContainerValue
160 *
161 * \param object the object on which the attribute of type ObjectVectorValue resides
162 * \param name the attribute name provided
163 * \param [in] vector the ObjectPtrContainerValue corresponding to the named attribute
164 */
166 std::string name,
167 const ObjectPtrContainerValue& vector);
168 /**
169 * End the visit to the attribute of type ns3::ObjectVectorValue.
170 */
172 /**
173 * Start to visit the object found in the input array at the provided index
174 * \param vector the array
175 * \param index the index into the array
176 * \param [in] item the array item to visit
177 */
179 uint32_t index,
180 Ptr<Object> item);
181 /**
182 * End the visit to the array item
183 */
184 void EndVisitArrayItem();
185
186 std::vector<Ptr<Object>> m_examined; ///< list of attributes examined
187 std::vector<std::string> m_currentPath; ///< current attribute path
188};
189
190} // namespace ns3
191
192#endif /* ATTRIBUTE_ITERATOR_H */
Iterator to iterate on the values of attributes of an ns3::Object.
void DoIterate(Ptr< Object > object)
Perform the iteration.
virtual void DoEndVisitArrayItem()
End the visit to the array item.
virtual void DoEndVisitPointerAttribute()
End the visit to the attribute of type ns3::PointerValue.
virtual void DoStartVisitPointerAttribute(Ptr< Object > object, std::string name, Ptr< Object > value)
Visit the attribute of type ns3::PointerValue, with the provided name, found on the object pointed to...
std::vector< std::string > m_currentPath
current attribute path
virtual void DoEndVisitArrayAttribute()
End the visit to the attribute of type ns3::ObjectVectorValue.
std::string GetCurrentPath() const
Get the current attribute path.
void StartVisitObject(Ptr< Object > object)
Start to visit an object to visit its attributes.
void EndVisitObject()
End the visit to the object.
bool IsExamined(Ptr< const Object > object)
Check if this object has already been examined.
void VisitAttribute(Ptr< Object > object, std::string name)
Visit attribute to perform a config store operation on it.
void StartVisitArrayAttribute(Ptr< Object > object, std::string name, const ObjectPtrContainerValue &vector)
Visit the attribute of type ns3::ObjectVectorValue, with the provided name, found on the object point...
virtual void DoVisitAttribute(Ptr< Object > object, std::string name)=0
This method visits and performs a config-store action (such as saving to a text file) on the attribut...
void EndVisitPointerAttribute()
End the visit to the attribute of type ns3::PointerValue.
void StartVisitArrayItem(const ObjectPtrContainerValue &vector, uint32_t index, Ptr< Object > item)
Start to visit the object found in the input array at the provided index.
void EndVisitArrayItem()
End the visit to the array item.
std::vector< Ptr< Object > > m_examined
list of attributes examined
virtual void DoStartVisitArrayItem(const ObjectPtrContainerValue &vector, uint32_t index, Ptr< Object > item)
Start to visit the object found in the input array at the provided index.
void EndVisitArrayAttribute()
End the visit to the attribute of type ns3::ObjectVectorValue.
virtual void DoStartVisitObject(Ptr< Object > object)
This method is called to start the process of visiting the input object.
void StartVisitPointerAttribute(Ptr< Object > object, std::string name, Ptr< Object > value)
Visit the attribute of type ns3::PointerValue, with the provided name, found on the object pointed to...
virtual void DoEndVisitObject()
This method is called to end the process of visiting the currently visited object.
virtual void DoStartVisitArrayAttribute(Ptr< Object > object, std::string name, const ObjectPtrContainerValue &vector)
Visit the attribute of type ns3::ObjectVectorValue, with the provided name, found on the object point...
void Iterate()
Start the process of iterating all objects from the root namespace object.
Container for a set of ns3::Object pointers.
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.