A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
model-typeid-creator.cc
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Faker Moatamri <faker.moatamri@sophia.inria.fr>
5 */
6
8
9namespace ns3
10{
11
15
16void
17
18ModelTypeidCreator::Build(GtkTreeStore* treestore)
19{
20 m_treestore = treestore;
21 m_iters.push_back(nullptr);
22 Iterate();
23 NS_ASSERT(m_iters.size() == 1);
24}
25
26void
28{
29 GtkTreeIter* parent = m_iters.back();
30 auto current = g_new(GtkTreeIter, 1);
31 gtk_tree_store_append(m_treestore, current, parent);
32 gtk_tree_store_set(m_treestore, current, COL_TYPEID, node, -1);
33 m_iters.push_back(current);
34}
35
36void
38{
39 GtkTreeIter* iter = m_iters.back();
40 g_free(iter);
41 m_iters.pop_back();
42}
43
44void
46 std::string name,
47 std::string defaultValue,
48 uint32_t index)
49{
50 auto node = new ModelTypeid();
51 node->type = ModelTypeid::NODE_ATTRIBUTE;
52 node->tid = tid;
53 node->name = name;
54 node->defaultValue = defaultValue;
55 node->index = index;
56 Add(node);
57 Remove();
58}
59
60void
62{
63 auto node = new ModelTypeid();
64 node->type = ModelTypeid::NODE_TYPEID;
65 node->tid = TypeId::LookupByName(name);
66 Add(node);
67}
68
69void
74} // end namespace ns3
void Iterate()
This function will go through all the TypeIds and get only the attributes which are explicit values (...
void EndVisitTypeId() override
Remove the last gtk tree iterator.
void StartVisitTypeId(std::string name) override
Add a node for the new TypeId object.
std::vector< GtkTreeIter * > m_iters
This contains a vector of iterators used to build the TreeStore.
void VisitAttribute(TypeId tid, std::string name, std::string defaultValue, uint32_t index) override
This method will add a ModelTypeid to the GtkTreeIterator.
void Build(GtkTreeStore *treestore)
This method will iterate on typeIds having default attributes and create a model for them,...
void Add(ModelTypeid *node)
Adds a treestore iterator to m_treestore model.
GtkTreeStore * m_treestore
this is the TreeStore model corresponding to the view
void Remove()
Removes the last GtkTreeIterator from m_iters.
a unique identifier for an interface.
Definition type-id.h:48
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition type-id.cc:872
#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.