A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
attribute-default-iterator.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Authors: Faker Moatamri <faker.moatamri@sophia.inria.fr>
17
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#include "
attribute-default-iterator.h
"
21
#include "ns3/attribute.h"
22
#include "ns3/pointer.h"
23
#include "ns3/callback.h"
24
#include "ns3/global-value.h"
25
#include "ns3/string.h"
26
#include "ns3/object-ptr-container.h"
27
28
namespace
ns3
29
{
30
31
AttributeDefaultIterator::~AttributeDefaultIterator
()
32
{
33
}
34
void
35
AttributeDefaultIterator::Iterate
(
void
)
36
{
37
for
(uint32_t i = 0; i <
TypeId::GetRegisteredN
(); i++)
38
{
39
TypeId
tid =
TypeId::GetRegistered
(i);
40
if
(tid.
MustHideFromDocumentation
())
41
{
42
continue
;
43
}
44
bool
calledStart =
false
;
45
for
(uint32_t j = 0; j < tid.
GetAttributeN
(); j++)
46
{
47
struct
TypeId::AttributeInformation
info = tid.
GetAttribute
(j);
48
if
(!(info.
flags
&
TypeId::ATTR_CONSTRUCT
))
49
{
50
// we can't construct the attribute, so, there is no
51
// initial value for the attribute
52
continue
;
53
}
54
//No accessor, go to next attribute
55
if
(info.
accessor
== 0)
56
{
57
continue
;
58
}
59
if
(!info.
accessor
->HasSetter ())
60
{
61
//skip this attribute it doesn't have an setter
62
continue
;
63
}
64
if
(info.
checker
== 0)
65
{
66
//skip, it doesn't have a checker
67
continue
;
68
}
69
if
(info.
initialValue
== 0)
70
{
71
//No value, check next attribute
72
continue
;
73
}
74
Ptr<const ObjectPtrContainerValue>
vector = DynamicCast<const ObjectPtrContainerValue> (info.
initialValue
);
75
if
(vector != 0)
76
{
77
//a vector value, won't take it
78
continue
;
79
}
80
Ptr<const PointerValue>
pointer = DynamicCast<const PointerValue> (info.
initialValue
);
81
if
(pointer != 0)
82
{
83
//pointer value, won't take it
84
continue
;
85
}
86
Ptr<const CallbackValue>
callback = DynamicCast<const CallbackValue> (info.
initialValue
);
87
if
(callback != 0)
88
{
89
//callback value, won't take it
90
continue
;
91
}
92
//We take only values, no pointers or vectors or callbacks
93
if
(!calledStart)
94
{
95
StartVisitTypeId
(tid.
GetName
());
96
}
97
VisitAttribute
(tid, info.
name
, info.
initialValue
->SerializeToString (info.
checker
), j);
98
calledStart =
true
;
99
}
100
if
(calledStart)
101
{
102
EndVisitTypeId
();
103
}
104
}
105
}
106
107
void
108
AttributeDefaultIterator::StartVisitTypeId
(std::string name)
109
{
110
}
111
void
112
AttributeDefaultIterator::EndVisitTypeId
(
void
)
113
{
114
}
115
116
void
117
AttributeDefaultIterator::DoVisitAttribute
(std::string name, std::string defaultValue)
118
{
119
}
120
121
void
122
AttributeDefaultIterator::VisitAttribute
(
TypeId
tid, std::string name, std::string defaultValue, uint32_t index)
123
{
124
DoVisitAttribute
(name, defaultValue);
125
}
126
127
}
// namespace ns3
ns3::TypeId::GetAttributeN
uint32_t GetAttributeN(void) const
Definition:
type-id.cc:739
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::TypeId::ATTR_CONSTRUCT
The attribute can be written at construction-time.
Definition:
type-id.h:58
ns3::TypeId::MustHideFromDocumentation
bool MustHideFromDocumentation(void) const
Definition:
type-id.cc:731
ns3::AttributeDefaultIterator::EndVisitTypeId
virtual void EndVisitTypeId(void)
Just an interface that needs to be implemented.
Definition:
attribute-default-iterator.cc:112
ns3::TypeId::AttributeInformation::accessor
Ptr< const AttributeAccessor > accessor
Definition:
type-id.h:67
attribute-default-iterator.h
ns3::TypeId::GetRegisteredN
static uint32_t GetRegisteredN(void)
Definition:
type-id.cc:576
ns3::TypeId::AttributeInformation::initialValue
Ptr< const AttributeValue > initialValue
Definition:
type-id.h:66
ns3::TypeId::GetRegistered
static TypeId GetRegistered(uint32_t i)
Definition:
type-id.cc:582
ns3::TypeId::AttributeInformation
Definition:
type-id.h:61
ns3::TypeId::AttributeInformation::flags
uint32_t flags
Definition:
type-id.h:64
ns3::AttributeDefaultIterator::~AttributeDefaultIterator
virtual ~AttributeDefaultIterator()=0
Definition:
attribute-default-iterator.cc:31
ns3::TypeId::AttributeInformation::checker
Ptr< const AttributeChecker > checker
Definition:
type-id.h:68
ns3::TypeId::AttributeInformation::name
std::string name
Definition:
type-id.h:62
ns3::TypeId::GetName
std::string GetName(void) const
Definition:
type-id.cc:658
ns3::AttributeDefaultIterator::Iterate
void Iterate(void)
This function will go through all the TypeIds and get only the attributes which are explicit values (...
Definition:
attribute-default-iterator.cc:35
ns3::AttributeDefaultIterator::DoVisitAttribute
virtual void DoVisitAttribute(std::string name, std::string defaultValue)
This method is just an interface and needs to be implemented.
Definition:
attribute-default-iterator.cc:117
ns3::AttributeDefaultIterator::VisitAttribute
virtual void VisitAttribute(TypeId tid, std::string name, std::string defaultValue, uint32_t index)
This method can be implemented, otherwise, it will call DoVisitAttribute.
Definition:
attribute-default-iterator.cc:122
ns3::TypeId::GetAttribute
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Definition:
type-id.cc:746
ns3::AttributeDefaultIterator::StartVisitTypeId
virtual void StartVisitTypeId(std::string name)
Just an interface that needs to be implemented.
Definition:
attribute-default-iterator.cc:108
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
src
config-store
model
attribute-default-iterator.cc
Generated on Sat Apr 19 2014 14:06:51 for ns-3 by
1.8.6