A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
boolean.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#include "
boolean.h
"
9
10
#include "
log.h
"
11
12
/**
13
* @file
14
* @ingroup attribute_Boolean
15
* ns3::BooleanValue attribute value implementation.
16
*/
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"Boolean"
);
22
23
BooleanValue::BooleanValue
()
24
:
m_value
(false)
25
{
26
NS_LOG_FUNCTION
(
this
);
27
}
28
29
BooleanValue::BooleanValue
(
const
bool
& value)
30
:
m_value
(value)
31
{
32
NS_LOG_FUNCTION
(
this
<< value);
33
}
34
35
void
36
BooleanValue::Set
(
bool
value)
37
{
38
NS_LOG_FUNCTION
(
this
<< value);
39
m_value
= value;
40
}
41
42
bool
43
BooleanValue::Get
()
const
44
{
45
NS_LOG_FUNCTION
(
this
);
46
return
m_value
;
47
}
48
49
BooleanValue::
50
operator bool()
const
51
{
52
return
m_value
;
53
}
54
55
std::ostream&
56
operator<<
(std::ostream& os,
const
BooleanValue
& value)
57
{
58
if
(value.Get())
59
{
60
os <<
"true"
;
61
}
62
else
63
{
64
os <<
"false"
;
65
}
66
return
os;
67
}
68
69
Ptr<AttributeValue>
70
BooleanValue::Copy
()
const
71
{
72
NS_LOG_FUNCTION
(
this
);
73
74
return
Create<BooleanValue>
(*
this
);
75
}
76
77
std::string
78
BooleanValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
79
{
80
NS_LOG_FUNCTION
(
this
<< checker);
81
82
if
(
m_value
)
83
{
84
return
"true"
;
85
}
86
else
87
{
88
return
"false"
;
89
}
90
}
91
92
bool
93
BooleanValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
94
{
95
NS_LOG_FUNCTION
(
this
<< value << checker);
96
97
if
(value ==
"true"
|| value ==
"1"
|| value ==
"t"
)
98
{
99
m_value
=
true
;
100
return
true
;
101
}
102
else
if
(value ==
"false"
|| value ==
"0"
|| value ==
"f"
)
103
{
104
m_value
=
false
;
105
return
true
;
106
}
107
else
108
{
109
return
false
;
110
}
111
}
112
113
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(Boolean,
"bool"
);
114
115
}
// namespace ns3
boolean.h
ns3::BooleanValue attribute value declarations.
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition
boolean.h:26
ns3::BooleanValue::Get
bool Get() const
Definition
boolean.cc:43
ns3::BooleanValue::Copy
Ptr< AttributeValue > Copy() const override
Definition
boolean.cc:70
ns3::BooleanValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition
boolean.cc:93
ns3::BooleanValue::BooleanValue
BooleanValue()
Definition
boolean.cc:23
ns3::BooleanValue::Set
void Set(bool value)
Set the value.
Definition
boolean.cc:36
ns3::BooleanValue::m_value
bool m_value
The stored Boolean instance.
Definition
boolean.h:46
ns3::BooleanValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition
boolean.cc:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MaketypeChecker function for class type.
Definition
attribute-helper.h:368
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
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:231
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:454
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:148
src
core
model
boolean.cc
Generated on
for ns-3 by
1.15.0