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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
double.cc
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
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Definition:
log.h:275
src
core
model
double.cc
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6