A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
double.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 "
double.h
"
21
#include "
object.h
"
22
#include "
log.h
"
23
#include <sstream>
24
31
namespace
ns3
{
32
33
NS_LOG_COMPONENT_DEFINE
(
"Double"
);
34
35
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(
double
,
Double
);
36
38
namespace
internal {
39
49
Ptr<const AttributeChecker>
MakeDoubleChecker
(
double
min
,
double
max
, std::string name)
50
{
51
NS_LOG_FUNCTION
(
min
<<
max
<< name);
52
53
struct
Checker :
public
AttributeChecker
54
{
55
Checker (
double
minValue,
double
maxValue, std::string name)
56
: m_minValue (minValue),
57
m_maxValue (maxValue),
58
m_name (name)
59
{}
60
virtual
bool
Check (
const
AttributeValue
&value)
const
61
{
62
NS_LOG_FUNCTION
(&value);
63
const
DoubleValue
*v =
dynamic_cast<
const
DoubleValue
*
>
(&value);
64
if
(v == 0)
65
{
66
return
false
;
67
}
68
return
v->
Get
() >= m_minValue && v->
Get
() <= m_maxValue;
69
}
70
virtual
std::string GetValueTypeName (
void
)
const
71
{
72
NS_LOG_FUNCTION_NOARGS
();
73
return
"ns3::DoubleValue"
;
74
}
75
virtual
bool
HasUnderlyingTypeInformation (
void
)
const
76
{
77
NS_LOG_FUNCTION_NOARGS
();
78
return
true
;
79
}
80
virtual
std::string GetUnderlyingTypeInformation (
void
)
const
81
{
82
NS_LOG_FUNCTION_NOARGS
();
83
std::ostringstream oss;
84
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
85
return
oss.str ();
86
}
87
virtual
Ptr<AttributeValue>
Create
(
void
)
const
88
{
89
NS_LOG_FUNCTION_NOARGS
();
90
return
ns3::Create<DoubleValue> ();
91
}
92
virtual
bool
Copy
(
const
AttributeValue
&source,
AttributeValue
&destination)
const
93
{
94
NS_LOG_FUNCTION
(&source << &destination);
95
const
DoubleValue
*src =
dynamic_cast<
const
DoubleValue
*
>
(&source);
96
DoubleValue
*dst =
dynamic_cast<
DoubleValue
*
>
(&destination);
97
if
(src == 0 || dst == 0)
98
{
99
return
false
;
100
}
101
*dst = *src;
102
return
true
;
103
}
104
double
m_minValue;
105
double
m_maxValue;
106
std::string m_name;
107
} *checker =
new
Checker (
min
,
max
, name);
108
return
Ptr<const AttributeChecker>
(checker,
false
);
109
}
110
111
}
// namespace internal
112
113
}
// namespace ns3
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::internal::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker(double min, double max, std::string name)
Make a Double attribute checker with embedded numeric type name.
Definition:
double.cc:49
double.h
ns3::DoubleValue attribute value declarations and template implementations.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:69
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:409
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
ns3::min
double min(double x, double y)
Definition:
cobalt-queue-disc.cc:132
ns3::AttributeChecker
Represent the type of an attribute.
Definition:
attribute.h:167
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition:
ptr.h:555
ns3::DoubleValue::Get
double Get(void) const
Definition:
double.cc:35
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:209
log.h
Debug message logging.
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:244
ns3::TracedValueCallback::Double
void(* Double)(double oldValue, double newValue)
TracedValue Callback signature for POD.
Definition:
traced-value.h:91
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type, name)
Define the class methods belonging to the attribute value class nameValue of the underlying class typ...
Definition:
attribute-helper.h:283
ns3::max
double max(double x, double y)
Definition:
cobalt-queue-disc.cc:137
object.h
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
src
core
model
double.cc
Generated on Fri Oct 1 2021 17:02:57 for ns-3 by
1.8.20