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