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
attribute-default-iterator.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
* Authors: Faker Moatamri <faker.moatamri@sophia.inria.fr>
16
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
17
*/
18
19
#include "
attribute-default-iterator.h
"
20
21
#include "ns3/attribute.h"
22
#include "ns3/callback.h"
23
#include "ns3/global-value.h"
24
#include "ns3/object-ptr-container.h"
25
#include "ns3/pointer.h"
26
#include "ns3/string.h"
27
28
namespace
ns3
29
{
30
31
AttributeDefaultIterator::~AttributeDefaultIterator
()
32
{
33
}
34
35
void
36
AttributeDefaultIterator::Iterate
()
37
{
38
for
(
uint32_t
i = 0; i <
TypeId::GetRegisteredN
(); i++)
39
{
40
TypeId
tid =
TypeId::GetRegistered
(i);
41
if
(tid.
MustHideFromDocumentation
())
42
{
43
continue
;
44
}
45
bool
calledStart =
false
;
46
for
(
uint32_t
j = 0; j < tid.
GetAttributeN
(); j++)
47
{
48
TypeId::AttributeInformation
info = tid.
GetAttribute
(j);
49
if
(!(info.
flags
&
TypeId::ATTR_CONSTRUCT
))
50
{
51
// we can't construct the attribute, so, there is no
52
// initial value for the attribute
53
continue
;
54
}
55
// No accessor, go to next attribute
56
if
(!info.
accessor
)
57
{
58
continue
;
59
}
60
if
(!info.
accessor
->HasSetter())
61
{
62
// skip this attribute it doesn't have an setter
63
continue
;
64
}
65
if
(!info.
checker
)
66
{
67
// skip, it doesn't have a checker
68
continue
;
69
}
70
if
(!info.
initialValue
)
71
{
72
// No value, check next attribute
73
continue
;
74
}
75
Ptr<const ObjectPtrContainerValue>
vector =
76
DynamicCast<const ObjectPtrContainerValue>(info.
initialValue
);
77
if
(vector)
78
{
79
// a vector value, won't take it
80
continue
;
81
}
82
Ptr<const PointerValue>
pointer = DynamicCast<const PointerValue>(info.
initialValue
);
83
if
(pointer)
84
{
85
// pointer value, won't take it
86
continue
;
87
}
88
Ptr<const CallbackValue>
callback = DynamicCast<const CallbackValue>(info.
initialValue
);
89
if
(callback)
90
{
91
// callback value, won't take it
92
continue
;
93
}
94
// We take only values, no pointers or vectors or callbacks
95
if
(!calledStart)
96
{
97
StartVisitTypeId
(tid.
GetName
());
98
}
99
VisitAttribute
(tid, info.
name
, info.
initialValue
->SerializeToString(info.
checker
), j);
100
calledStart =
true
;
101
}
102
if
(calledStart)
103
{
104
EndVisitTypeId
();
105
}
106
}
107
}
108
109
void
110
AttributeDefaultIterator::StartVisitTypeId
(std::string name)
111
{
112
}
113
114
void
115
AttributeDefaultIterator::EndVisitTypeId
()
116
{
117
}
118
119
void
120
AttributeDefaultIterator::DoVisitAttribute
(std::string name, std::string defaultValue)
121
{
122
}
123
124
void
125
AttributeDefaultIterator::VisitAttribute
(
TypeId
tid,
126
std::string name,
127
std::string defaultValue,
128
uint32_t
index)
129
{
130
DoVisitAttribute
(name, defaultValue);
131
}
132
133
}
// namespace ns3
attribute-default-iterator.h
ns3::AttributeDefaultIterator::~AttributeDefaultIterator
virtual ~AttributeDefaultIterator()=0
Definition:
attribute-default-iterator.cc:31
ns3::AttributeDefaultIterator::VisitAttribute
virtual void VisitAttribute(TypeId tid, std::string name, std::string defaultValue, uint32_t index)
Visit an Attribute.
Definition:
attribute-default-iterator.cc:125
ns3::AttributeDefaultIterator::EndVisitTypeId
virtual void EndVisitTypeId()
End the analysis of a TypeId.
Definition:
attribute-default-iterator.cc:115
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::AttributeDefaultIterator::DoVisitAttribute
virtual void DoVisitAttribute(std::string name, std::string defaultValue)
Visit an Attribute.
Definition:
attribute-default-iterator.cc:120
ns3::AttributeDefaultIterator::StartVisitTypeId
virtual void StartVisitTypeId(std::string name)
Begin the analysis of a TypeId.
Definition:
attribute-default-iterator.cc:110
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::MustHideFromDocumentation
bool MustHideFromDocumentation() const
Check if this TypeId should not be listed in documentation.
Definition:
type-id.cc:1092
ns3::TypeId::ATTR_CONSTRUCT
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
Definition:
type-id.h:66
ns3::TypeId::GetRegisteredN
static uint16_t GetRegisteredN()
Get the number of registered TypeIds.
Definition:
type-id.cc:879
ns3::TypeId::GetAttributeN
std::size_t GetAttributeN() const
Get the number of attributes.
Definition:
type-id.cc:1100
ns3::TypeId::GetRegistered
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
Definition:
type-id.cc:886
ns3::TypeId::GetAttribute
TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
Definition:
type-id.cc:1108
ns3::TypeId::GetName
std::string GetName() const
Get the name.
Definition:
type-id.cc:991
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TypeId::AttributeInformation
Attribute implementation.
Definition:
type-id.h:81
ns3::TypeId::AttributeInformation::name
std::string name
Attribute name.
Definition:
type-id.h:83
ns3::TypeId::AttributeInformation::accessor
Ptr< const AttributeAccessor > accessor
Accessor object.
Definition:
type-id.h:93
ns3::TypeId::AttributeInformation::flags
uint32_t flags
AttributeFlags value.
Definition:
type-id.h:87
ns3::TypeId::AttributeInformation::checker
Ptr< const AttributeChecker > checker
Checker object.
Definition:
type-id.h:95
ns3::TypeId::AttributeInformation::initialValue
Ptr< const AttributeValue > initialValue
Configured initial value.
Definition:
type-id.h:91
src
config-store
model
attribute-default-iterator.cc
Generated on Thu Feb 8 2024 09:24:21 for ns-3 by
1.9.6