A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
model-typeid-creator.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Author: Faker Moatamri <faker.moatamri@sophia.inria.fr>
16
*/
17
18
#include "
model-typeid-creator.h
"
19
20
namespace
ns3
21
{
22
23
ModelTypeidCreator::ModelTypeidCreator
()
24
{
25
}
26
27
void
28
29
ModelTypeidCreator::Build
(GtkTreeStore* treestore)
30
{
31
m_treestore
= treestore;
32
m_iters
.push_back(
nullptr
);
33
Iterate
();
34
NS_ASSERT
(
m_iters
.size() == 1);
35
}
36
37
void
38
ModelTypeidCreator::Add
(
ModelTypeid
* node)
39
{
40
GtkTreeIter* parent =
m_iters
.back();
41
auto
current = g_new(GtkTreeIter, 1);
42
gtk_tree_store_append(
m_treestore
, current, parent);
43
gtk_tree_store_set(
m_treestore
, current,
COL_TYPEID
, node, -1);
44
m_iters
.push_back(current);
45
}
46
47
void
48
ModelTypeidCreator::Remove
()
49
{
50
GtkTreeIter* iter =
m_iters
.back();
51
g_free(iter);
52
m_iters
.pop_back();
53
}
54
55
void
56
ModelTypeidCreator::VisitAttribute
(
TypeId
tid,
57
std::string name,
58
std::string defaultValue,
59
uint32_t index)
60
{
61
auto
node =
new
ModelTypeid
();
62
node->type =
ModelTypeid::NODE_ATTRIBUTE
;
63
node->tid = tid;
64
node->name = name;
65
node->defaultValue = defaultValue;
66
node->index = index;
67
Add
(node);
68
Remove
();
69
}
70
71
void
72
ModelTypeidCreator::StartVisitTypeId
(std::string name)
73
{
74
auto
node =
new
ModelTypeid
();
75
node->type =
ModelTypeid::NODE_TYPEID
;
76
node->tid =
TypeId::LookupByName
(name);
77
Add
(node);
78
}
79
80
void
81
ModelTypeidCreator::EndVisitTypeId
()
82
{
83
Remove
();
84
}
85
}
// 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:36
ns3::ModelTypeidCreator::EndVisitTypeId
void EndVisitTypeId() override
Remove the last gtk tree iterator.
Definition:
model-typeid-creator.cc:81
ns3::ModelTypeidCreator::StartVisitTypeId
void StartVisitTypeId(std::string name) override
Add a node for the new TypeId object.
Definition:
model-typeid-creator.cc:72
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:110
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:56
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:29
ns3::ModelTypeidCreator::ModelTypeidCreator
ModelTypeidCreator()
Definition:
model-typeid-creator.cc:23
ns3::ModelTypeidCreator::Add
void Add(ModelTypeid *node)
Adds a treestore iterator to m_treestore model.
Definition:
model-typeid-creator.cc:38
ns3::ModelTypeidCreator::m_treestore
GtkTreeStore * m_treestore
this is the TreeStore model corresponding to the view
Definition:
model-typeid-creator.h:108
ns3::ModelTypeidCreator::Remove
void Remove()
Removes the last GtkTreeIterator from m_iters.
Definition:
model-typeid-creator.cc:48
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::LookupByName
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition:
type-id.cc:835
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:66
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:30
ns3::ModelTypeid
A class used in the implementation of the GtkConfigStore.
Definition:
model-typeid-creator.h:39
ns3::ModelTypeid::NODE_TYPEID
@ NODE_TYPEID
Definition:
model-typeid-creator.h:48
ns3::ModelTypeid::NODE_ATTRIBUTE
@ NODE_ATTRIBUTE
Definition:
model-typeid-creator.h:46
src
config-store
model
model-typeid-creator.cc
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1