A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
attribute.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "
attribute.h
"
21
#include "
log.h
"
22
#include "
fatal-error.h
"
23
#include "
string.h
"
24
#include <sstream>
25
33
namespace
ns3
{
34
35
NS_LOG_COMPONENT_DEFINE
(
"AttributeValue"
);
36
37
AttributeValue::AttributeValue
()
38
{}
39
AttributeValue::~AttributeValue
()
40
{}
41
42
43
AttributeAccessor::AttributeAccessor
()
44
{}
45
AttributeAccessor::~AttributeAccessor
()
46
{}
47
48
AttributeChecker::AttributeChecker
()
49
{}
50
AttributeChecker::~AttributeChecker
()
51
{}
52
53
Ptr<AttributeValue>
54
AttributeChecker::CreateValidValue
(
const
AttributeValue
&value)
const
55
{
56
NS_LOG_FUNCTION
(
this
<< &value);
57
if
(
Check
(value))
58
{
59
return
value.
Copy
();
60
}
61
// attempt to convert to string.
62
const
StringValue
*str =
dynamic_cast<
const
StringValue
*
>
(&value);
63
if
(str == 0)
64
{
65
return
0;
66
}
67
// attempt to convert back to value.
68
Ptr<AttributeValue>
v =
Create
();
69
bool
ok = v->DeserializeFromString (str->
Get
(),
this
);
70
if
(!ok)
71
{
72
return
0;
73
}
74
ok =
Check
(*v);
75
if
(!ok)
76
{
77
return
0;
78
}
79
return
v;
80
}
81
82
EmptyAttributeValue::EmptyAttributeValue
()
83
{
84
NS_LOG_FUNCTION
(
this
);
85
}
86
Ptr<AttributeValue>
87
EmptyAttributeValue::Copy
(
void
)
const
88
{
89
NS_LOG_FUNCTION
(
this
);
90
return
Create<EmptyAttributeValue> ();
91
}
92
std::string
93
EmptyAttributeValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
94
{
95
NS_LOG_FUNCTION
(
this
<< checker);
96
return
""
;
97
}
98
bool
99
EmptyAttributeValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
100
{
101
NS_LOG_FUNCTION
(
this
<< value << checker);
102
return
true
;
103
}
104
105
EmptyAttributeAccessor::EmptyAttributeAccessor
() :
AttributeAccessor
()
106
{}
107
108
EmptyAttributeAccessor::~EmptyAttributeAccessor
()
109
{}
110
111
bool
112
EmptyAttributeAccessor::Set
(
ObjectBase
*
object
,
const
AttributeValue
&value)
const
113
{
114
(void)
object
;
115
(void) value;
116
return
true
;
117
}
118
119
bool
120
EmptyAttributeAccessor::Get
(
const
ObjectBase
*
object
,
AttributeValue
&attribute)
const
121
{
122
(void)
object
;
123
(void) attribute;
124
return
true
;
125
}
126
127
bool
128
EmptyAttributeAccessor::HasGetter
(
void
)
const
129
{
130
return
false
;
131
}
132
133
bool
134
EmptyAttributeAccessor::HasSetter
(
void
)
const
135
{
136
return
false
;
137
}
138
139
EmptyAttributeChecker::EmptyAttributeChecker
() :
AttributeChecker
()
140
{}
141
142
EmptyAttributeChecker::~EmptyAttributeChecker
()
143
{}
144
145
bool
146
EmptyAttributeChecker::Check
(
const
AttributeValue
&value)
const
147
{
148
(void) value;
149
return
true
;
150
}
151
152
std::string
153
EmptyAttributeChecker::GetValueTypeName
(
void
)
const
154
{
155
return
"EmptyAttribute"
;
156
}
157
158
bool
159
EmptyAttributeChecker::HasUnderlyingTypeInformation
(
void
)
const
160
{
161
return
false
;
162
}
163
164
std::string
165
EmptyAttributeChecker::GetUnderlyingTypeInformation
(
void
)
const
166
{
167
return
""
;
168
}
169
170
Ptr<AttributeValue>
171
EmptyAttributeChecker::Create
(
void
)
const
172
{
173
static
EmptyAttributeValue
t;
174
return
Ptr<AttributeValue>
(&t,
false
);
175
}
176
177
bool
178
EmptyAttributeChecker::Copy
(
const
AttributeValue
&source,
AttributeValue
&destination)
const
179
{
180
(void) source;
181
(void) destination;
182
return
true
;
183
}
184
185
186
}
// namespace ns3
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::AttributeChecker::Check
virtual bool Check(const AttributeValue &value) const =0
ns3::AttributeChecker::~AttributeChecker
virtual ~AttributeChecker()
Definition:
attribute.cc:50
fatal-error.h
NS_FATAL_x macro definitions.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AttributeValue::~AttributeValue
virtual ~AttributeValue()
Definition:
attribute.cc:39
ns3::AttributeAccessor::AttributeAccessor
AttributeAccessor()
Definition:
attribute.cc:43
ns3::EmptyAttributeAccessor::EmptyAttributeAccessor
EmptyAttributeAccessor()
Definition:
attribute.cc:105
ns3::AttributeValue::AttributeValue
AttributeValue()
Definition:
attribute.cc:37
string.h
ns3::StringValue attribute value declarations.
ns3::EmptyAttributeAccessor::Set
virtual bool Set(ObjectBase *object, const AttributeValue &value) const
Definition:
attribute.cc:112
ns3::EmptyAttributeChecker::GetUnderlyingTypeInformation
virtual std::string GetUnderlyingTypeInformation(void) const
Definition:
attribute.cc:165
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:69
ns3::EmptyAttributeAccessor::HasGetter
virtual bool HasGetter(void) const
Definition:
attribute.cc:128
ns3::EmptyAttributeChecker::HasUnderlyingTypeInformation
virtual bool HasUnderlyingTypeInformation(void) const
Definition:
attribute.cc:159
ns3::AttributeChecker::AttributeChecker
AttributeChecker()
Definition:
attribute.cc:48
ns3::EmptyAttributeAccessor::HasSetter
virtual bool HasSetter(void) const
Definition:
attribute.cc:134
ns3::AttributeAccessor::~AttributeAccessor
virtual ~AttributeAccessor()
Definition:
attribute.cc:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
ns3::EmptyAttributeChecker::GetValueTypeName
virtual std::string GetValueTypeName(void) const
Definition:
attribute.cc:153
ns3::AttributeValue::Copy
virtual Ptr< AttributeValue > Copy(void) const =0
ns3::AttributeChecker
Represent the type of an attribute.
Definition:
attribute.h:167
ns3::EmptyAttributeAccessor::Get
virtual bool Get(const ObjectBase *object, AttributeValue &attribute) const
Definition:
attribute.cc:120
attribute.h
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
ns3::EmptyAttributeValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition:
attribute.cc:99
ns3::StringValue::Get
std::string Get(void) const
Definition:
string.cc:31
ns3::AttributeAccessor
allow setting and getting the value of an attribute.
Definition:
attribute.h:115
ns3::StringValue
Hold variables of type string.
Definition:
string.h:41
ns3::EmptyAttributeValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
attribute.cc:87
log.h
Debug message logging.
ns3::EmptyAttributeValue
A class for an empty attribute value.
Definition:
attribute.h:233
ns3::AttributeChecker::CreateValidValue
Ptr< AttributeValue > CreateValidValue(const AttributeValue &value) const
Create a valid value from the argument value, or reinterpret the argument as a string.
Definition:
attribute.cc:54
ns3::EmptyAttributeChecker::Check
virtual bool Check(const AttributeValue &value) const
Definition:
attribute.cc:146
ns3::EmptyAttributeValue::EmptyAttributeValue
EmptyAttributeValue()
Default constructor.
Definition:
attribute.cc:82
ns3::EmptyAttributeChecker::~EmptyAttributeChecker
~EmptyAttributeChecker()
Definition:
attribute.cc:142
ns3::EmptyAttributeValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition:
attribute.cc:93
ns3::EmptyAttributeChecker::EmptyAttributeChecker
EmptyAttributeChecker()
Definition:
attribute.cc:139
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ns3::EmptyAttributeChecker::Create
virtual Ptr< AttributeValue > Create(void) const
Definition:
attribute.cc:171
ns3::EmptyAttributeChecker::Copy
virtual bool Copy(const AttributeValue &source, AttributeValue &destination) const
Copy the source to the destination.
Definition:
attribute.cc:178
ns3::AttributeChecker::Create
virtual Ptr< AttributeValue > Create(void) const =0
ns3::EmptyAttributeAccessor::~EmptyAttributeAccessor
~EmptyAttributeAccessor()
Definition:
attribute.cc:108
ns3::ObjectBase
Anchor the ns-3 type and attribute system.
Definition:
object-base.h:120
src
core
model
attribute.cc
Generated on Fri Oct 1 2021 17:02:57 for ns-3 by
1.8.20