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
uinteger.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 "uinteger.h"
21
#include "fatal-error.h"
22
#include "log.h"
23
#include <sstream>
24
25
NS_LOG_COMPONENT_DEFINE
(
"Uinteger"
);
26
27
namespace
ns3 {
28
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (uint64_t,Uinteger);
30
31
namespace
internal {
32
33
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max, std::string name)
34
{
35
NS_LOG_FUNCTION
(min << max << name);
36
struct
Checker :
public
AttributeChecker
37
{
38
Checker (uint64_t minValue, uint64_t maxValue, std::string name)
39
: m_minValue (minValue),
40
m_maxValue (maxValue),
41
m_name (name) {}
42
virtual
bool
Check (
const
AttributeValue &value)
const
{
43
NS_LOG_FUNCTION
(&value);
44
const
UintegerValue *v =
dynamic_cast<
const
UintegerValue *
>
(&value);
45
if
(v == 0)
46
{
47
return
false
;
48
}
49
return
v->Get () >= m_minValue && v->Get () <= m_maxValue;
50
}
51
virtual
std::string GetValueTypeName (
void
)
const
{
52
NS_LOG_FUNCTION_NOARGS
();
53
return
"ns3::UintegerValue"
;
54
}
55
virtual
bool
HasUnderlyingTypeInformation (
void
)
const
{
56
NS_LOG_FUNCTION_NOARGS
();
57
return
true
;
58
}
59
virtual
std::string GetUnderlyingTypeInformation (
void
)
const
{
60
NS_LOG_FUNCTION_NOARGS
();
61
std::ostringstream oss;
62
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
63
return
oss.str ();
64
}
65
virtual
Ptr<AttributeValue> Create (
void
)
const
{
66
NS_LOG_FUNCTION_NOARGS
();
67
return
ns3::Create<UintegerValue> ();
68
}
69
virtual
bool
Copy (
const
AttributeValue &source, AttributeValue &destination)
const
{
70
NS_LOG_FUNCTION
(&source << &destination);
71
const
UintegerValue *src =
dynamic_cast<
const
UintegerValue *
>
(&source);
72
UintegerValue *dst =
dynamic_cast<
UintegerValue *
>
(&destination);
73
if
(src == 0 || dst == 0)
74
{
75
return
false
;
76
}
77
*dst = *src;
78
return
true
;
79
}
80
uint64_t m_minValue;
81
uint64_t m_maxValue;
82
std::string m_name;
83
} *checker =
new
Checker (min, max, name);
84
return
Ptr<const AttributeChecker> (checker,
false
);
85
}
86
87
}
// namespace internal
88
89
}
// 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
uinteger.cc
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6