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
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
}
40
AttributeValue::~AttributeValue
()
41
{
42
}
43
44
45
AttributeAccessor::AttributeAccessor
()
46
{
47
}
48
AttributeAccessor::~AttributeAccessor
()
49
{
50
}
51
52
AttributeChecker::AttributeChecker
()
53
{
54
}
55
AttributeChecker::~AttributeChecker
()
56
{
57
}
58
59
Ptr<AttributeValue>
60
AttributeChecker::CreateValidValue
(
const
AttributeValue
&value)
const
61
{
62
NS_LOG_FUNCTION
(
this
<< &value);
63
if
(
Check
(value))
64
{
65
return
value.
Copy
();
66
}
67
// attempt to convert to string.
68
const
StringValue
*str =
dynamic_cast<
const
StringValue
*
>
(&value);
69
if
(str == 0)
70
{
71
return
0;
72
}
73
// attempt to convert back to value.
74
Ptr<AttributeValue>
v =
Create
();
75
bool
ok = v->DeserializeFromString (str->
Get
(),
this
);
76
if
(!ok)
77
{
78
return
0;
79
}
80
ok =
Check
(*v);
81
if
(!ok)
82
{
83
return
0;
84
}
85
return
v;
86
}
87
88
EmptyAttributeValue::EmptyAttributeValue
()
89
{
90
NS_LOG_FUNCTION
(
this
);
91
}
92
Ptr<AttributeValue>
93
EmptyAttributeValue::Copy
(
void
)
const
94
{
95
NS_LOG_FUNCTION
(
this
);
96
return
Create<EmptyAttributeValue> ();
97
}
98
std::string
99
EmptyAttributeValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
100
{
101
NS_LOG_FUNCTION
(
this
<< checker);
102
return
""
;
103
}
104
bool
105
EmptyAttributeValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
106
{
107
NS_LOG_FUNCTION
(
this
<< value << checker);
108
return
true
;
109
}
110
111
112
}
// namespace ns3
fatal-error.h
NS_FATAL_x macro definitions.
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
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:213
ns3::StringValue::Get
std::string Get(void) const
Definition:
string.cc:31
ns3::AttributeAccessor::AttributeAccessor
AttributeAccessor()
Definition:
attribute.cc:45
ns3::StringValue
Hold variables of type string.
Definition:
string.h:41
string.h
String attribute value declarations.
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:68
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::EmptyAttributeValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition:
attribute.cc:105
ns3::EmptyAttributeValue::EmptyAttributeValue
EmptyAttributeValue()
Default constructor.
Definition:
attribute.cc:88
ns3::AttributeValue::AttributeValue
AttributeValue()
Definition:
attribute.cc:37
ns3::AttributeAccessor::~AttributeAccessor
virtual ~AttributeAccessor()
Definition:
attribute.cc:48
ns3::AttributeChecker::AttributeChecker
AttributeChecker()
Definition:
attribute.cc:52
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:60
attribute.h
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
ns3::EmptyAttributeValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition:
attribute.cc:99
ns3::AttributeValue::~AttributeValue
virtual ~AttributeValue()
Definition:
attribute.cc:40
ns3::AttributeValue::Copy
virtual Ptr< AttributeValue > Copy(void) const =0
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AttributeChecker::Create
virtual Ptr< AttributeValue > Create(void) const =0
ns3::AttributeChecker::~AttributeChecker
virtual ~AttributeChecker()
Definition:
attribute.cc:55
log.h
Debug message logging.
ns3::AttributeChecker::Check
virtual bool Check(const AttributeValue &value) const =0
ns3::EmptyAttributeValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
attribute.cc:93
src
core
model
attribute.cc
Generated on Wed Sep 30 2015 15:55:27 for ns-3 by
1.8.9.1