A Discrete-Event Network Simulator
API
model-node-creator.cc
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  * Authors: Faker Moatamri <faker.moatamri@sophia.inria.fr>
17  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 
20 #include "model-node-creator.h"
21 namespace ns3 {
22 
24 {
25 }
26 void
27 
28 ModelCreator::Build (GtkTreeStore *treestore)
29 {
30  m_treestore = treestore;
31  m_iters.push_back (0);
32  //this function will go through all the objects and call on them
33  //DoStartVisitObject, DoIterate and DoEndVisitObject
34  Iterate ();
35  NS_ASSERT (m_iters.size () == 1);
36 }
37 
38 
39 void
41 {
42  GtkTreeIter *parent = m_iters.back ();
43  GtkTreeIter *current = g_new (GtkTreeIter, 1);
44  gtk_tree_store_append (m_treestore, current, parent);
45  gtk_tree_store_set (m_treestore, current,
46  COL_NODE, node, -1);
47  m_iters.push_back (current);
48 }
49 void
51 {
52  GtkTreeIter *iter = m_iters.back ();
53  g_free (iter);
54  m_iters.pop_back ();
55 }
56 
57 void
58 ModelCreator::DoVisitAttribute (Ptr<Object> object, std::string name)
59 {
60  ModelNode *node = new ModelNode ();
62  node->object = object;
63  node->name = name;
64  Add (node);
65  Remove ();
66 }
67 void
69 {
70  ModelNode *node = new ModelNode ();
72  node->object = object;
73  Add (node);
74 }
75 void
77 {
78  Remove ();
79 }
80 void
82 {
83  ModelNode *node = new ModelNode ();
85  node->object = object;
86  node->name = name;
87  Add (node);
88 }
89 void
91 {
92  Remove ();
93 }
94 void
96 {
97  ModelNode *node = new ModelNode ();
99  node->object = object;
100  node->name = name;
101  Add (node);
102 }
103 void
105 {
106  Remove ();
107 }
108 void
110 {
111  GtkTreeIter *parent = m_iters.back ();
112  GtkTreeIter *current = g_new (GtkTreeIter, 1);
113  ModelNode *node = new ModelNode ();
115  node->object = item;
116  node->index = index;
117  gtk_tree_store_append (m_treestore, current, parent);
118  gtk_tree_store_set (m_treestore, current,
119  COL_NODE, node,
120  -1);
121  m_iters.push_back (current);
122 }
123 void
125 {
126  GtkTreeIter *iter = m_iters.back ();
127  g_free (iter);
128  m_iters.pop_back ();
129 }
130 } //end namespace ns3
ns3::ModelCreator::m_treestore
GtkTreeStore * m_treestore
attribute tree
Definition: model-node-creator.h:94
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
model-node-creator.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ModelNode::NODE_POINTER
@ NODE_POINTER
Definition: model-node-creator.h:47
ns3::ModelCreator::DoStartVisitArrayItem
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.
Definition: model-node-creator.cc:109
ns3::ModelCreator::DoEndVisitArrayItem
virtual void DoEndVisitArrayItem(void)
End the visit to the array item.
Definition: model-node-creator.cc:124
ns3::ModelCreator::ModelCreator
ModelCreator()
Definition: model-node-creator.cc:23
ns3::ModelNode::object
Ptr< Object > object
the object
Definition: model-node-creator.h:56
ns3::ObjectPtrContainerValue
Container for a set of ns3::Object pointers.
Definition: object-ptr-container.h:46
ns3::AttributeIterator::Iterate
void Iterate(void)
Start the process of iterating all objects from the root namespace object.
Definition: attribute-iterator.cc:41
ns3::ModelNode::name
std::string name
node name
Definition: model-node-creator.h:55
ns3::Ptr< Object >
ns3::ModelNode::NODE_VECTOR
@ NODE_VECTOR
Definition: model-node-creator.h:49
ns3::ModelCreator::Build
void Build(GtkTreeStore *treestore)
Allocate attribute tree.
Definition: model-node-creator.cc:28
ns3::ModelNode::type
enum ns3::ModelNode::@1 type
node type
ns3::ModelCreator::DoEndVisitObject
virtual void DoEndVisitObject(void)
This method is called to end the process of visiting the currently visited object.
Definition: model-node-creator.cc:76
ns3::ModelCreator::Remove
void Remove(void)
Remove current tree item.
Definition: model-node-creator.cc:50
ns3::ModelCreator::Add
void Add(ModelNode *node)
Add item to attribute tree.
Definition: model-node-creator.cc:40
ns3::ModelCreator::DoEndVisitArrayAttribute
virtual void DoEndVisitArrayAttribute(void)
End the visit to the attribute of type ns3::ObjectVectorValue.
Definition: model-node-creator.cc:104
ns3::ModelCreator::m_iters
std::vector< GtkTreeIter * > m_iters
attribute tree item
Definition: model-node-creator.h:95
ns3::ModelNode::NODE_VECTOR_ITEM
@ NODE_VECTOR_ITEM
Definition: model-node-creator.h:51
ns3::ModelCreator::DoEndVisitPointerAttribute
virtual void DoEndVisitPointerAttribute(void)
End the visit to the attribute of type ns3::PointerValue.
Definition: model-node-creator.cc:90
ns3::ModelNode::NODE_ATTRIBUTE
@ NODE_ATTRIBUTE
Definition: model-node-creator.h:45
ns3::ModelNode
A class used in the implementation of the GtkConfigStore.
Definition: model-node-creator.h:36
ns3::COL_NODE
@ COL_NODE
Definition: model-node-creator.h:28
ns3::ModelNode::index
uint32_t index
index
Definition: model-node-creator.h:57
ns3::ModelCreator::DoStartVisitArrayAttribute
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...
Definition: model-node-creator.cc:95
ns3::ModelCreator::DoVisitAttribute
virtual void DoVisitAttribute(Ptr< Object > object, std::string name)
This method visits and performs a config-store action (such as saving to a text file) on the attribut...
Definition: model-node-creator.cc:58
ns3::ModelCreator::DoStartVisitObject
virtual void DoStartVisitObject(Ptr< Object > object)
This method is called to start the process of visiting the input object.
Definition: model-node-creator.cc:68
ns3::ModelCreator::DoStartVisitPointerAttribute
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...
Definition: model-node-creator.cc:81
ns3::ModelNode::NODE_OBJECT
@ NODE_OBJECT
Definition: model-node-creator.h:53