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
boolean.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 "
boolean.h
"
21
#include "
fatal-error.h
"
22
#include "
log.h
"
23
24
NS_LOG_COMPONENT_DEFINE
(
"Boolean"
);
25
26
namespace
ns3 {
27
28
BooleanValue::BooleanValue
()
29
: m_value (false)
30
{
31
NS_LOG_FUNCTION
(
this
);
32
}
33
BooleanValue::BooleanValue
(
bool
value)
34
: m_value (value)
35
{
36
NS_LOG_FUNCTION
(
this
<< value);
37
}
38
void
39
BooleanValue::Set
(
bool
value)
40
{
41
NS_LOG_FUNCTION
(
this
<< value);
42
m_value
= value;
43
}
44
bool
45
BooleanValue::Get
(
void
)
const
46
{
47
NS_LOG_FUNCTION
(
this
);
48
return
m_value
;
49
}
50
BooleanValue::operator bool ()
const
51
{
52
return
m_value;
53
}
54
55
std::ostream &
operator <<
(std::ostream &os,
const
BooleanValue
&value)
56
{
57
if
(value.
Get
())
58
{
59
os <<
"true"
;
60
}
61
else
62
{
63
os <<
"false"
;
64
}
65
return
os;
66
}
67
68
Ptr<AttributeValue>
69
BooleanValue::Copy
(
void
)
const
70
{
71
NS_LOG_FUNCTION
(
this
);
72
73
return
Create<BooleanValue> (*this);
74
}
75
std::string
76
BooleanValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
77
{
78
NS_LOG_FUNCTION
(
this
<< checker);
79
80
if
(
m_value
)
81
{
82
return
"true"
;
83
}
84
else
85
{
86
return
"false"
;
87
}
88
}
89
bool
90
BooleanValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
91
{
92
NS_LOG_FUNCTION
(
this
<< value << checker);
93
94
if
(value ==
"true"
||
95
value ==
"1"
||
96
value ==
"t"
)
97
{
98
m_value
=
true
;
99
return
true
;
100
}
101
else
if
(value ==
"false"
||
102
value ==
"0"
||
103
value ==
"f"
)
104
{
105
m_value
=
false
;
106
return
true
;
107
}
108
else
109
{
110
return
false
;
111
}
112
}
113
114
115
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(Boolean,
"bool"
);
116
117
}
// namespace ns3
src
core
model
boolean.cc
Generated on Fri Dec 21 2012 19:00:32 for ns-3 by
1.8.1.2