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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
attribute.cc
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
26
NS_LOG_COMPONENT_DEFINE
(
"AttributeValue"
);
27
28
namespace
ns3 {
29
30
AttributeValue::AttributeValue ()
31
{
32
}
33
AttributeValue::~AttributeValue ()
34
{
35
}
36
37
38
AttributeAccessor::AttributeAccessor ()
39
{
40
}
41
AttributeAccessor::~AttributeAccessor ()
42
{
43
}
44
45
AttributeChecker::AttributeChecker ()
46
{
47
}
48
AttributeChecker::~AttributeChecker ()
49
{
50
}
51
52
Ptr<AttributeValue>
53
AttributeChecker::CreateValidValue (
const
AttributeValue &value)
const
54
{
55
NS_LOG_FUNCTION
(
this
<< &value);
56
if
(
Check
(value))
57
{
58
return
value.Copy ();
59
}
60
// attempt to convert to string.
61
const
StringValue *str =
dynamic_cast<
const
StringValue *
>
(&value);
62
if
(str == 0)
63
{
64
return
0;
65
}
66
// attempt to convert back to value.
67
Ptr<AttributeValue> v =
Create
();
68
bool
ok = v->DeserializeFromString (str->Get (),
this
);
69
if
(!ok)
70
{
71
return
0;
72
}
73
ok =
Check
(*v);
74
if
(!ok)
75
{
76
return
0;
77
}
78
return
v;
79
}
80
81
EmptyAttributeValue::EmptyAttributeValue ()
82
{
83
NS_LOG_FUNCTION
(
this
);
84
}
85
Ptr<AttributeValue>
86
EmptyAttributeValue::Copy
(
void
)
const
87
{
88
NS_LOG_FUNCTION
(
this
);
89
return
Create<EmptyAttributeValue> ();
90
}
91
std::string
92
EmptyAttributeValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
93
{
94
NS_LOG_FUNCTION
(
this
<< checker);
95
return
""
;
96
}
97
bool
98
EmptyAttributeValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
99
{
100
NS_LOG_FUNCTION
(
this
<< value << checker);
101
return
true
;
102
}
103
104
105
}
// namespace ns3
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::EmptyAttributeValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition:
attribute.cc:98
ns3::EmptyAttributeValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition:
attribute.cc:92
ns3::AttributeChecker::Create
virtual Ptr< AttributeValue > Create(void) const =0
ns3::AttributeChecker::Check
virtual bool Check(const AttributeValue &value) const =0
ns3::EmptyAttributeValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
attribute.cc:86
src
core
model
attribute.cc
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6