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
uinteger.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 "
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
fatal-error.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
uinteger.h
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
ns3::internal::MakeUintegerChecker
Ptr< const AttributeChecker > MakeUintegerChecker(uint64_t min, uint64_t max, std::string name)
Definition:
uinteger.cc:33
ns3::UintegerValue::Get
uint64_t Get(void) const
ns3::Create
Ptr< T > Create(void)
Definition:
ptr.h:231
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:46
ns3::ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(double, Double)
log.h
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("Uinteger")
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Definition:
ptr.h:387
src
core
model
uinteger.cc
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6