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
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
25
NS_LOG_COMPONENT_DEFINE
(
"Double"
);
26
27
namespace
ns3 {
28
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(
double
, Double);
30
31
namespace
internal {
32
33
Ptr<const AttributeChecker>
MakeDoubleChecker
(
double
min,
double
max, std::string name)
34
{
35
NS_LOG_FUNCTION
(min << max << name);
36
37
struct
Checker :
public
AttributeChecker
38
{
39
Checker (
double
minValue,
double
maxValue, std::string name)
40
: m_minValue (minValue),
41
m_maxValue (maxValue),
42
m_name (name) {}
43
virtual
bool
Check (
const
AttributeValue
&value)
const
{
44
NS_LOG_FUNCTION
(&value);
45
const
DoubleValue
*v =
dynamic_cast<
const
DoubleValue
*
>
(&value);
46
if
(v == 0)
47
{
48
return
false
;
49
}
50
return
v->
Get
() >= m_minValue && v->
Get
() <= m_maxValue;
51
}
52
virtual
std::string GetValueTypeName (
void
)
const
{
53
NS_LOG_FUNCTION_NOARGS
();
54
return
"ns3::DoubleValue"
;
55
}
56
virtual
bool
HasUnderlyingTypeInformation (
void
)
const
{
57
NS_LOG_FUNCTION_NOARGS
();
58
return
true
;
59
}
60
virtual
std::string GetUnderlyingTypeInformation (
void
)
const
{
61
NS_LOG_FUNCTION_NOARGS
();
62
std::ostringstream oss;
63
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
64
return
oss.str ();
65
}
66
virtual
Ptr<AttributeValue>
Create
(
void
)
const
{
67
NS_LOG_FUNCTION_NOARGS
();
68
return
ns3::Create<DoubleValue> ();
69
}
70
virtual
bool
Copy
(
const
AttributeValue
&source,
AttributeValue
&destination)
const
{
71
NS_LOG_FUNCTION
(&source << &destination);
72
const
DoubleValue
*src =
dynamic_cast<
const
DoubleValue
*
>
(&source);
73
DoubleValue
*dst =
dynamic_cast<
DoubleValue
*
>
(&destination);
74
if
(src == 0 || dst == 0)
75
{
76
return
false
;
77
}
78
*dst = *src;
79
return
true
;
80
}
81
double
m_minValue;
82
double
m_maxValue;
83
std::string m_name;
84
} *checker =
new
Checker (min, max, name);
85
return
Ptr<const AttributeChecker>
(checker,
false
);
86
}
87
88
}
// namespace internal
89
90
}
// namespace ns3
double.h
ns3::AttributeChecker
Represent the type of an attribute.
Definition:
attribute.h:154
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
ns3::Create
Ptr< T > Create(void)
Definition:
ptr.h:231
ns3::ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(double, Double)
ns3::DoubleValue::Get
double Get(void) const
object.h
log.h
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::internal::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker(double min, double max, std::string name)
Definition:
double.cc:33
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("Double")
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Definition:
ptr.h:387
src
core
model
double.cc
Generated on Sat Apr 19 2014 14:06:51 for ns-3 by
1.8.6