A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
attribute-iterator.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
16 */
17
18#ifndef ATTRIBUTE_ITERATOR_H
19#define ATTRIBUTE_ITERATOR_H
20
21#include "ns3/object-ptr-container.h"
22#include "ns3/object.h"
23#include "ns3/ptr.h"
24
25#include <vector>
26
27namespace ns3
28{
29
30/**
31 * \ingroup configstore
32 *
33 * \brief Iterator to iterate on the values of attributes of an ns3::Object
34 * \note This class is used internally by ConfigStore and GtkConfigStore.
35 */
37{
38 public:
40 virtual ~AttributeIterator();
41
42 /**
43 * Start the process of iterating all objects from the root namespace object
44 */
45 void Iterate();
46
47 protected:
48 /**
49 * Get the current attribute path
50 * \returns the current path string
51 */
52 std::string GetCurrentPath() const;
53
54 private:
55 /**
56 * This method visits and performs a config-store action (such as saving
57 * to a text file) on the attribute values corresponding to the input
58 * object pointer and attribute name.
59 *
60 * \param object the object visited
61 * \param name the attribute name
62 */
63 virtual void DoVisitAttribute(Ptr<Object> object, std::string name) = 0;
64 /**
65 * This method is called to start the process of visiting the input object
66 * \param object the object visited
67 */
68 virtual void DoStartVisitObject(Ptr<Object> object);
69 /**
70 * This method is called to end the process of visiting the currently
71 * visited object.
72 */
73 virtual void DoEndVisitObject();
74 /**
75 * Visit the attribute of type ns3::PointerValue, with the provided name,
76 * found on the object pointed to by the first argument.
77 *
78 * \param object the object on which the attribute of type PointerValue resides
79 * \param name the attribute name provided
80 * \param [in] value Ptr to the ns3::Object pointed to by the attribute
81 */
82 virtual void DoStartVisitPointerAttribute(Ptr<Object> object,
83 std::string name,
84 Ptr<Object> value);
85 /**
86 * End the visit to the attribute of type ns3::PointerValue.
87 */
88 virtual void DoEndVisitPointerAttribute();
89 /**
90 * Visit the attribute of type ns3::ObjectVectorValue, with the
91 * provided name, found on the object pointed to by the first argument.
92 *
93 * \note type name ObjectVectorValue is an alias for ObjectPtrContainerValue
94 *
95 * \param object the object on which the attribute of type ObjectVectorValue resides
96 * \param name the attribute name provided
97 * \param [in] vector the ObjectPtrContainerValue corresponding to the named attribute
98 */
99 virtual void DoStartVisitArrayAttribute(Ptr<Object> object,
100 std::string name,
101 const ObjectPtrContainerValue& vector);
102 /**
103 * End the visit to the attribute of type ns3::ObjectVectorValue.
104 */
105 virtual void DoEndVisitArrayAttribute();
106 /**
107 * Start to visit the object found in the input array at the provided index
108 * \param vector the array
109 * \param index the index into the array
110 * \param [in] item the array item to visit
111 */
112 virtual void DoStartVisitArrayItem(const ObjectPtrContainerValue& vector,
113 uint32_t index,
114 Ptr<Object> item);
115 /**
116 * End the visit to the array item
117 */
118 virtual void DoEndVisitArrayItem();
119
120 /**
121 * Perform the iteration
122 * \param object the object visited
123 */
124 void DoIterate(Ptr<Object> object);
125 /**
126 * Check if this object has already been examined
127 * \param object the object to check
128 * \returns true if object has been examined
129 */
130 bool IsExamined(Ptr<const Object> object);
131 /**
132 * Get current attribute path
133 * \param attr the current attribute string
134 * \returns the current path string
135 */
136 std::string GetCurrentPath(std::string attr) const;
137
138 /**
139 * Visit attribute to perform a config store operation on it
140 * \param object the current object
141 * \param name the attribute name
142 */
143 void VisitAttribute(Ptr<Object> object, std::string name);
144 /**
145 * Start to visit an object to visit its attributes
146 * \param object the current object
147 */
148 void StartVisitObject(Ptr<Object> object);
149 /**
150 * End the visit to the object
151 */
152 void EndVisitObject();
153 /**
154 * Visit the attribute of type ns3::PointerValue, with the provided name,
155 * found on the object pointed to by the first argument.
156 *
157 * \param object the object on which the attribute of type PointerValue resides
158 * \param name the attribute name provided
159 * \param [in] value Ptr to the ns3::Object pointed to by the attribute
160 */
161 void StartVisitPointerAttribute(Ptr<Object> object, std::string name, Ptr<Object> value);
162 /**
163 * End the visit to the attribute of type ns3::PointerValue.
164 */
166 /**
167 * Visit the attribute of type ns3::ObjectVectorValue, with the
168 * provided name, found on the object pointed to by the first argument.
169 *
170 * \note type name ObjectVectorValue is an alias for ObjectPtrContainerValue
171 *
172 * \param object the object on which the attribute of type ObjectVectorValue resides
173 * \param name the attribute name provided
174 * \param [in] vector the ObjectPtrContainerValue corresponding to the named attribute
175 */
177 std::string name,
178 const ObjectPtrContainerValue& vector);
179 /**
180 * End the visit to the attribute of type ns3::ObjectVectorValue.
181 */
183 /**
184 * Start to visit the object found in the input array at the provided index
185 * \param vector the array
186 * \param index the index into the array
187 * \param [in] item the array item to visit
188 */
190 uint32_t index,
191 Ptr<Object> item);
192 /**
193 * End the visit to the array item
194 */
195 void EndVisitArrayItem();
196
197 std::vector<Ptr<Object>> m_examined; ///< list of attributes examined
198 std::vector<std::string> m_currentPath; ///< current attribute path
199};
200
201} // namespace ns3
202
203#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.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.