A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
7
#include "
model-typeid-creator.h
"
8
9
namespace
ns3
10
{
11
12
ModelTypeidCreator::ModelTypeidCreator
()
13
{
14
}
15
16
void
17
18
ModelTypeidCreator::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
26
void
27
ModelTypeidCreator::Add
(
ModelTypeid
* node)
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
36
void
37
ModelTypeidCreator::Remove
()
38
{
39
GtkTreeIter* iter =
m_iters
.back();
40
g_free(iter);
41
m_iters
.pop_back();
42
}
43
44
void
45
ModelTypeidCreator::VisitAttribute
(
TypeId
tid,
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
60
void
61
ModelTypeidCreator::StartVisitTypeId
(std::string name)
62
{
63
auto
node =
new
ModelTypeid
();
64
node->type =
ModelTypeid::NODE_TYPEID
;
65
node->tid =
TypeId::LookupByName
(name);
66
Add
(node);
67
}
68
69
void
70
ModelTypeidCreator::EndVisitTypeId
()
71
{
72
Remove
();
73
}
74
}
// end namespace ns3
ns3::AttributeDefaultIterator::Iterate
void Iterate()
This function will go through all the TypeIds and get only the attributes which are explicit values (...
Definition
attribute-default-iterator.cc:25
ns3::ModelTypeidCreator::EndVisitTypeId
void EndVisitTypeId() override
Remove the last gtk tree iterator.
Definition
model-typeid-creator.cc:70
ns3::ModelTypeidCreator::StartVisitTypeId
void StartVisitTypeId(std::string name) override
Add a node for the new TypeId object.
Definition
model-typeid-creator.cc:61
ns3::ModelTypeidCreator::m_iters
std::vector< GtkTreeIter * > m_iters
This contains a vector of iterators used to build the TreeStore.
Definition
model-typeid-creator.h:99
ns3::ModelTypeidCreator::VisitAttribute
void VisitAttribute(TypeId tid, std::string name, std::string defaultValue, uint32_t index) override
This method will add a ModelTypeid to the GtkTreeIterator.
Definition
model-typeid-creator.cc:45
ns3::ModelTypeidCreator::Build
void Build(GtkTreeStore *treestore)
This method will iterate on typeIds having default attributes and create a model for them,...
Definition
model-typeid-creator.cc:18
ns3::ModelTypeidCreator::ModelTypeidCreator
ModelTypeidCreator()
Definition
model-typeid-creator.cc:12
ns3::ModelTypeidCreator::Add
void Add(ModelTypeid *node)
Adds a treestore iterator to m_treestore model.
Definition
model-typeid-creator.cc:27
ns3::ModelTypeidCreator::m_treestore
GtkTreeStore * m_treestore
this is the TreeStore model corresponding to the view
Definition
model-typeid-creator.h:97
ns3::ModelTypeidCreator::Remove
void Remove()
Removes the last GtkTreeIterator from m_iters.
Definition
model-typeid-creator.cc:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::LookupByName
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition
type-id.cc:872
uint32_t
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:55
model-typeid-creator.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::COL_TYPEID
@ COL_TYPEID
Definition
model-typeid-creator.h:19
ns3::ModelTypeid
A class used in the implementation of the GtkConfigStore.
Definition
model-typeid-creator.h:28
ns3::ModelTypeid::NODE_TYPEID
@ NODE_TYPEID
Definition
model-typeid-creator.h:37
ns3::ModelTypeid::NODE_ATTRIBUTE
@ NODE_ATTRIBUTE
Definition
model-typeid-creator.h:35
src
config-store
model
model-typeid-creator.cc
Generated on Sat Nov 2 2024 19:37:21 for ns-3 by
1.11.0