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 <sstream>
23
24
namespace
ns3 {
25
26
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(
double
, Double);
27
28
namespace
internal {
29
30
Ptr<const AttributeChecker>
MakeDoubleChecker
(
double
min,
double
max, std::string name)
31
{
32
struct
Checker :
public
AttributeChecker
33
{
34
Checker (
double
minValue,
double
maxValue, std::string name)
35
: m_minValue (minValue),
36
m_maxValue (maxValue),
37
m_name (name) {}
38
virtual
bool
Check (
const
AttributeValue
&value)
const
{
39
const
DoubleValue
*v =
dynamic_cast<
const
DoubleValue
*
>
(&value);
40
if
(v == 0)
41
{
42
return
false
;
43
}
44
return
v->
Get
() >= m_minValue && v->
Get
() <= m_maxValue;
45
}
46
virtual
std::string GetValueTypeName (
void
)
const
{
47
return
"ns3::DoubleValue"
;
48
}
49
virtual
bool
HasUnderlyingTypeInformation (
void
)
const
{
50
return
true
;
51
}
52
virtual
std::string GetUnderlyingTypeInformation (
void
)
const
{
53
std::ostringstream oss;
54
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
55
return
oss.str ();
56
}
57
virtual
Ptr<AttributeValue>
Create
(
void
)
const
{
58
return
ns3::Create<DoubleValue> ();
59
}
60
virtual
bool
Copy
(
const
AttributeValue
&source,
AttributeValue
&destination)
const
{
61
const
DoubleValue
*src =
dynamic_cast<
const
DoubleValue
*
>
(&source);
62
DoubleValue
*dst =
dynamic_cast<
DoubleValue
*
>
(&destination);
63
if
(src == 0 || dst == 0)
64
{
65
return
false
;
66
}
67
*dst = *src;
68
return
true
;
69
}
70
double
m_minValue;
71
double
m_maxValue;
72
std::string m_name;
73
} *checker =
new
Checker (min, max, name);
74
return
Ptr<const AttributeChecker>
(checker,
false
);
75
}
76
77
}
// namespace internal
78
79
}
// namespace ns3
src
core
model
double.cc
Generated on Tue Nov 13 2012 10:32:10 for ns-3 by
1.8.1.2