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
30
namespace
ns3 {
31
32
NS_LOG_COMPONENT_DEFINE
(
"Boolean"
);
33
34
BooleanValue::BooleanValue
()
35
: m_value (false)
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
BooleanValue::BooleanValue
(
bool
value)
40
: m_value (value)
41
{
42
NS_LOG_FUNCTION
(
this
<< value);
43
}
44
void
45
BooleanValue::Set
(
bool
value)
46
{
47
NS_LOG_FUNCTION
(
this
<< value);
48
m_value
= value;
49
}
50
bool
51
BooleanValue::Get
(
void
)
const
52
{
53
NS_LOG_FUNCTION
(
this
);
54
return
m_value
;
55
}
56
BooleanValue::operator bool ()
const
57
{
58
return
m_value;
59
}
60
61
std::ostream &
operator <<
(std::ostream &os,
const
BooleanValue
&value)
62
{
63
if
(value.
Get
())
64
{
65
os <<
"true"
;
66
}
67
else
68
{
69
os <<
"false"
;
70
}
71
return
os;
72
}
73
74
Ptr<AttributeValue>
75
BooleanValue::Copy
(
void
)
const
76
{
77
NS_LOG_FUNCTION
(
this
);
78
79
return
Create<BooleanValue> (*this);
80
}
81
std::string
82
BooleanValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
83
{
84
NS_LOG_FUNCTION
(
this
<< checker);
85
86
if
(
m_value
)
87
{
88
return
"true"
;
89
}
90
else
91
{
92
return
"false"
;
93
}
94
}
95
bool
96
BooleanValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
97
{
98
NS_LOG_FUNCTION
(
this
<< value << checker);
99
100
if
(value ==
"true"
||
101
value ==
"1"
||
102
value ==
"t"
)
103
{
104
m_value
=
true
;
105
return
true
;
106
}
107
else
if
(value ==
"false"
||
108
value ==
"0"
||
109
value ==
"f"
)
110
{
111
m_value
=
false
;
112
return
true
;
113
}
114
else
115
{
116
return
false
;
117
}
118
}
119
120
121
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(Boolean,
"bool"
);
122
123
}
// namespace ns3
fatal-error.h
NS_FATAL_x macro definitions.
boolean.h
Boolean attribute value declarations.
ns3::BooleanValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
boolean.cc:75
ns3::BooleanValue::Get
bool Get(void) const
Definition:
boolean.cc:51
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
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:213
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition:
boolean.h:34
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::BooleanValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition:
boolean.cc:96
ns3::BooleanValue::Set
void Set(bool value)
Set the value.
Definition:
boolean.cc:45
ns3::BooleanValue::BooleanValue
BooleanValue()
Definition:
boolean.cc:34
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition:
angles.cc:42
ns3::BooleanValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition:
boolean.cc:82
ns3::BooleanValue::m_value
bool m_value
The stored Boolean instance.
Definition:
boolean.h:59
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MakeTypeChecker function for class type.
Definition:
attribute-helper.h:350
log.h
Debug message logging.
src
core
model
boolean.cc
Generated on Wed Jul 6 2016 17:11:25 for ns-3 by
1.8.6