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
void Iterate(void)
Start the process of iterating all objects from the root namespace object.
GtkTreeStore * m_treestore
attribute tree
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.
virtual void DoEndVisitArrayItem(void)
End the visit to the array item.
void Remove(void)
Remove current tree item.
virtual void DoEndVisitPointerAttribute(void)
End the visit to the attribute of type ns3::PointerValue.
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...
virtual void DoEndVisitArrayAttribute(void)
End the visit to the attribute of type ns3::ObjectVectorValue.
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...
virtual void DoStartVisitObject(Ptr< Object > object)
This method is called to start the process of visiting the input object.
virtual void DoEndVisitObject(void)
This method is called to end the process of visiting the currently visited object.
std::vector< GtkTreeIter * > m_iters
attribute tree item
void Build(GtkTreeStore *treestore)
Allocate attribute tree.
void Add(ModelNode *node)
Add item to attribute tree.
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...
Container for a set of ns3::Object pointers.
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
A class used in the implementation of the GtkConfigStore.
enum ns3::ModelNode::@2 type
node type
Ptr< Object > object
the object
uint32_t index
index
std::string name
node name