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 "
fatal-error.h
"
11
#include "
log.h
"
12
13
/**
14
* @file
15
* @ingroup attribute_Boolean
16
* ns3::BooleanValue attribute value implementation.
17
*/
18
19
namespace
ns3
20
{
21
22
NS_LOG_COMPONENT_DEFINE
(
"Boolean"
);
23
24
BooleanValue::BooleanValue
()
25
:
m_value
(false)
26
{
27
NS_LOG_FUNCTION
(
this
);
28
}
29
30
BooleanValue::BooleanValue
(
const
bool
& value)
31
:
m_value
(value)
32
{
33
NS_LOG_FUNCTION
(
this
<< value);
34
}
35
36
void
37
BooleanValue::Set
(
bool
value)
38
{
39
NS_LOG_FUNCTION
(
this
<< value);
40
m_value
= value;
41
}
42
43
bool
44
BooleanValue::Get
()
const
45
{
46
NS_LOG_FUNCTION
(
this
);
47
return
m_value
;
48
}
49
50
BooleanValue::
51
operator bool()
const
52
{
53
return
m_value
;
54
}
55
56
std::ostream&
57
operator<<
(std::ostream& os,
const
BooleanValue
& value)
58
{
59
if
(value.Get())
60
{
61
os <<
"true"
;
62
}
63
else
64
{
65
os <<
"false"
;
66
}
67
return
os;
68
}
69
70
Ptr<AttributeValue>
71
BooleanValue::Copy
()
const
72
{
73
NS_LOG_FUNCTION
(
this
);
74
75
return
Create<BooleanValue>
(*
this
);
76
}
77
78
std::string
79
BooleanValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
80
{
81
NS_LOG_FUNCTION
(
this
<< checker);
82
83
if
(
m_value
)
84
{
85
return
"true"
;
86
}
87
else
88
{
89
return
"false"
;
90
}
91
}
92
93
bool
94
BooleanValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
95
{
96
NS_LOG_FUNCTION
(
this
<< value << checker);
97
98
if
(value ==
"true"
|| value ==
"1"
|| value ==
"t"
)
99
{
100
m_value
=
true
;
101
return
true
;
102
}
103
else
if
(value ==
"false"
|| value ==
"0"
|| value ==
"f"
)
104
{
105
m_value
=
false
;
106
return
true
;
107
}
108
else
109
{
110
return
false
;
111
}
112
}
113
114
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(Boolean,
"bool"
);
115
116
}
// 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:44
ns3::BooleanValue::Copy
Ptr< AttributeValue > Copy() const override
Definition
boolean.cc:71
ns3::BooleanValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition
boolean.cc:94
ns3::BooleanValue::BooleanValue
BooleanValue()
Definition
boolean.cc:24
ns3::BooleanValue::Set
void Set(bool value)
Set the value.
Definition
boolean.cc:37
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:79
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:67
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:368
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
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:439
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 Fri Oct 3 2025 18:22:03 for ns-3 by
1.13.2