A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
boolean.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
#include "
boolean.h
"
20
21
#include "
fatal-error.h
"
22
#include "
log.h
"
23
30
namespace
ns3
31
{
32
33
NS_LOG_COMPONENT_DEFINE
(
"Boolean"
);
34
35
BooleanValue::BooleanValue
()
36
: m_value(false)
37
{
38
NS_LOG_FUNCTION
(
this
);
39
}
40
41
BooleanValue::BooleanValue
(
bool
value)
42
: m_value(value)
43
{
44
NS_LOG_FUNCTION
(
this
<< value);
45
}
46
47
void
48
BooleanValue::Set
(
bool
value)
49
{
50
NS_LOG_FUNCTION
(
this
<< value);
51
m_value
= value;
52
}
53
54
bool
55
BooleanValue::Get
()
const
56
{
57
NS_LOG_FUNCTION
(
this
);
58
return
m_value
;
59
}
60
61
BooleanValue::operator bool()
const
62
{
63
return
m_value;
64
}
65
66
std::ostream&
67
operator<<
(std::ostream& os,
const
BooleanValue
& value)
68
{
69
if
(value.Get())
70
{
71
os <<
"true"
;
72
}
73
else
74
{
75
os <<
"false"
;
76
}
77
return
os;
78
}
79
80
Ptr<AttributeValue>
81
BooleanValue::Copy
()
const
82
{
83
NS_LOG_FUNCTION
(
this
);
84
85
return
Create<BooleanValue>(*
this
);
86
}
87
88
std::string
89
BooleanValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
90
{
91
NS_LOG_FUNCTION
(
this
<< checker);
92
93
if
(
m_value
)
94
{
95
return
"true"
;
96
}
97
else
98
{
99
return
"false"
;
100
}
101
}
102
103
bool
104
BooleanValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
105
{
106
NS_LOG_FUNCTION
(
this
<< value << checker);
107
108
if
(value ==
"true"
|| value ==
"1"
|| value ==
"t"
)
109
{
110
m_value
=
true
;
111
return
true
;
112
}
113
else
if
(value ==
"false"
|| value ==
"0"
|| value ==
"f"
)
114
{
115
m_value
=
false
;
116
return
true
;
117
}
118
else
119
{
120
return
false
;
121
}
122
}
123
124
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(Boolean,
"bool"
);
125
126
}
// namespace ns3
boolean.h
ns3::BooleanValue attribute value declarations.
ns3::BooleanValue
Definition:
boolean.h:37
ns3::BooleanValue::Get
bool Get() const
Definition:
boolean.cc:55
ns3::BooleanValue::Copy
Ptr< AttributeValue > Copy() const override
Definition:
boolean.cc:81
ns3::BooleanValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition:
boolean.cc:104
ns3::BooleanValue::BooleanValue
BooleanValue()
Definition:
boolean.cc:35
ns3::BooleanValue::Set
void Set(bool value)
Definition:
boolean.cc:48
ns3::BooleanValue::m_value
bool m_value
Definition:
boolean.h:62
ns3::BooleanValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition:
boolean.cc:89
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
fatal-error.h
NS_FATAL_x macro definitions.
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MaketypeChecker function for class type.
Definition:
attribute-helper.h:380
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:159
src
core
model
boolean.cc
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1