A Discrete-Event Network Simulator
API
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 
27 namespace ns3
28 {
29 
37 {
38  public:
40  virtual ~AttributeIterator();
41 
45  void Iterate();
46 
47  protected:
52  std::string GetCurrentPath() const;
53 
54  private:
63  virtual void DoVisitAttribute(Ptr<Object> object, std::string name) = 0;
68  virtual void DoStartVisitObject(Ptr<Object> object);
73  virtual void DoEndVisitObject();
82  virtual void DoStartVisitPointerAttribute(Ptr<Object> object,
83  std::string name,
84  Ptr<Object> value);
88  virtual void DoEndVisitPointerAttribute();
99  virtual void DoStartVisitArrayAttribute(Ptr<Object> object,
100  std::string name,
101  const ObjectPtrContainerValue& vector);
105  virtual void DoEndVisitArrayAttribute();
112  virtual void DoStartVisitArrayItem(const ObjectPtrContainerValue& vector,
113  uint32_t index,
114  Ptr<Object> item);
118  virtual void DoEndVisitArrayItem();
119 
124  void DoIterate(Ptr<Object> object);
130  bool IsExamined(Ptr<const Object> object);
136  std::string GetCurrentPath(std::string attr) const;
137 
143  void VisitAttribute(Ptr<Object> object, std::string name);
148  void StartVisitObject(Ptr<Object> object);
152  void EndVisitObject();
161  void StartVisitPointerAttribute(Ptr<Object> object, std::string name, Ptr<Object> value);
177  std::string name,
178  const ObjectPtrContainerValue& vector);
182  void EndVisitArrayAttribute();
189  void StartVisitArrayItem(const ObjectPtrContainerValue& vector,
190  uint32_t index,
191  Ptr<Object> item);
195  void EndVisitArrayItem();
196 
197  std::vector<Ptr<Object>> m_examined;
198  std::vector<std::string> m_currentPath;
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.