A Discrete-Event Network Simulator
API
attribute-iterator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
17  */
18 
19 #ifndef ATTRIBUTE_ITERATOR_H
20 #define ATTRIBUTE_ITERATOR_H
21 
22 #include "ns3/ptr.h"
23 #include "ns3/object.h"
24 #include "ns3/object-ptr-container.h"
25 #include <vector>
26 
27 namespace ns3 {
28 
36 {
37 public:
39  virtual ~AttributeIterator ();
40 
44  void Iterate (void);
45 protected:
50  std::string GetCurrentPath (void) const;
51 private:
60  virtual void DoVisitAttribute (Ptr<Object> object, std::string name) = 0;
65  virtual void DoStartVisitObject (Ptr<Object> object);
70  virtual void DoEndVisitObject (void);
79  virtual void DoStartVisitPointerAttribute (Ptr<Object> object, std::string name, Ptr<Object> value);
83  virtual void DoEndVisitPointerAttribute (void);
95  virtual void DoStartVisitArrayAttribute (Ptr<Object> object, std::string name, const ObjectPtrContainerValue &vector);
99  virtual void DoEndVisitArrayAttribute (void);
106  virtual void DoStartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr<Object> item);
110  virtual void DoEndVisitArrayItem (void);
111 
116  void DoIterate (Ptr<Object> object);
122  bool IsExamined (Ptr<const Object> object);
128  std::string GetCurrentPath (std::string attr) const;
129 
135  void VisitAttribute (Ptr<Object> object, std::string name);
140  void StartVisitObject (Ptr<Object> object);
144  void EndVisitObject (void);
153  void StartVisitPointerAttribute (Ptr<Object> object, std::string name, Ptr<Object> value);
157  void EndVisitPointerAttribute (void);
169  void StartVisitArrayAttribute (Ptr<Object> object, std::string name, const ObjectPtrContainerValue &vector);
173  void EndVisitArrayAttribute (void);
180  void StartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr<Object> item);
184  void EndVisitArrayItem (void);
185 
186 
187  std::vector<Ptr<Object> > m_examined;
188  std::vector<std::string> m_currentPath;
189 };
190 
191 } // namespace ns3
192 
193 #endif /* ATTRIBUTE_ITERATOR_H */
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...
virtual void DoEndVisitObject(void)
This method is called to end the process of visiting the currently visited object.
void EndVisitPointerAttribute(void)
End the visit to the attribute of type ns3::PointerValue.
virtual void DoEndVisitPointerAttribute(void)
End the visit to the attribute of type ns3::PointerValue.
virtual void DoEndVisitArrayAttribute(void)
End the visit to the attribute of type ns3::ObjectVectorValue.
bool IsExamined(Ptr< const Object > object)
Check if this object has already been examined.
std::vector< std::string > m_currentPath
current attribute path
void EndVisitArrayItem(void)
End the visit to the array item.
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 poi...
void StartVisitObject(Ptr< Object > object)
Start to visit an object to visit its attributes.
std::vector< Ptr< Object > > m_examined
list of attributes examined
virtual void DoStartVisitObject(Ptr< Object > object)
This method is called to start the process of visiting the input object.
void VisitAttribute(Ptr< Object > object, std::string name)
Visit attribute to perform a config store operation on it.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetCurrentPath(void) const
Get the current attribute path.
virtual void DoEndVisitArrayItem(void)
End the visit to the array item.
void DoIterate(Ptr< Object > object)
Perform the iteration.
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(void)
End the visit to the attribute of type ns3::ObjectVectorValue.
Iterator to iterate on the values of attributes of an ns3::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...
Container for a set of ns3::Object pointers.
void Iterate(void)
Start the process of iterating all objects from the root namespace 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 poi...
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 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 EndVisitObject(void)
End the visit to the object.