A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
model-node-creator.cc
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Authors: Faker Moatamri <faker.moatamri@sophia.inria.fr>
5 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
6 */
7
9
10namespace ns3
11{
12
16
17void
18
19ModelCreator::Build(GtkTreeStore* treestore)
20{
21 m_treestore = treestore;
22 m_iters.push_back(nullptr);
23 // this function will go through all the objects and call on them
24 // DoStartVisitObject, DoIterate and DoEndVisitObject
25 Iterate();
26 NS_ASSERT(m_iters.size() == 1);
27}
28
29void
31{
32 GtkTreeIter* parent = m_iters.back();
33 auto current = g_new(GtkTreeIter, 1);
34 gtk_tree_store_append(m_treestore, current, parent);
35 gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1);
36 m_iters.push_back(current);
37}
38
39void
41{
42 GtkTreeIter* iter = m_iters.back();
43 g_free(iter);
44 m_iters.pop_back();
45}
46
47void
49{
50 auto node = new ModelNode();
51 node->type = ModelNode::NODE_ATTRIBUTE;
52 node->object = object;
53 node->name = name;
54 Add(node);
55 Remove();
56}
57
58void
60{
61 auto node = new ModelNode();
62 node->type = ModelNode::NODE_OBJECT;
63 node->object = object;
64 Add(node);
65}
66
67void
72
73void
75{
76 auto node = new ModelNode();
77 node->type = ModelNode::NODE_POINTER;
78 node->object = object;
79 node->name = name;
80 Add(node);
81}
82
83void
88
89void
91 std::string name,
92 const ObjectPtrContainerValue& vector)
93{
94 auto node = new ModelNode();
95 node->type = ModelNode::NODE_VECTOR;
96 node->object = object;
97 node->name = name;
98 Add(node);
99}
100
101void
106
107void
109 uint32_t index,
110 Ptr<Object> item)
111{
112 GtkTreeIter* parent = m_iters.back();
113 auto current = g_new(GtkTreeIter, 1);
114 auto node = new ModelNode();
115 node->type = ModelNode::NODE_VECTOR_ITEM;
116 node->object = item;
117 node->index = index;
118 gtk_tree_store_append(m_treestore, current, parent);
119 gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1);
120 m_iters.push_back(current);
121}
122
123void
125{
126 GtkTreeIter* iter = m_iters.back();
127 g_free(iter);
128 m_iters.pop_back();
129}
130} // end namespace ns3
void Iterate()
Start the process of iterating all objects from the root namespace object.
void DoEndVisitArrayAttribute() override
End the visit to the attribute of type ns3::ObjectVectorValue.
void DoEndVisitPointerAttribute() override
End the visit to the attribute of type ns3::PointerValue.
GtkTreeStore * m_treestore
attribute tree
void DoStartVisitObject(Ptr< Object > object) override
This method is called to start the process of visiting the input object.
void DoStartVisitPointerAttribute(Ptr< Object > object, std::string name, Ptr< Object > value) override
Visit the attribute of type ns3::PointerValue, with the provided name, found on the object pointed to...
void DoStartVisitArrayItem(const ObjectPtrContainerValue &vector, uint32_t index, Ptr< Object > item) override
Start to visit the object found in the input array at the provided index.
std::vector< GtkTreeIter * > m_iters
attribute tree item
void Build(GtkTreeStore *treestore)
Allocate attribute tree.
void DoStartVisitArrayAttribute(Ptr< Object > object, std::string name, const ObjectPtrContainerValue &vector) override
Visit the attribute of type ns3::ObjectVectorValue, with the provided name, found on the object point...
void Add(ModelNode *node)
Add item to attribute tree.
void Remove()
Remove current tree item.
void DoEndVisitArrayItem() override
End the visit to the array item.
void DoEndVisitObject() override
This method is called to end the process of visiting the currently visited object.
void DoVisitAttribute(Ptr< Object > object, std::string name) override
This method visits and performs a config-store action (such as saving to a text file) on the attribut...
Container for a set of ns3::Object pointers.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
Every class exported by the ns3 library is enclosed in the ns3 namespace.
A class used in the implementation of the GtkConfigStore.