A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
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
31
namespace
ns3
{
32
33
NS_LOG_COMPONENT_DEFINE
(
"Uinteger"
);
34
35
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(uint64_t,Uinteger);
36
37
namespace
internal {
38
48
Ptr<const AttributeChecker>
MakeUintegerChecker
(uint64_t
min
, uint64_t
max
, std::string name)
49
{
50
NS_LOG_FUNCTION
(
min
<<
max
<< name);
51
struct
Checker :
public
AttributeChecker
52
{
53
Checker (uint64_t minValue, uint64_t maxValue, std::string name)
54
: m_minValue (minValue),
55
m_maxValue (maxValue),
56
m_name (name)
57
{}
58
virtual
bool
Check (
const
AttributeValue
&value)
const
59
{
60
NS_LOG_FUNCTION
(&value);
61
const
UintegerValue
*v =
dynamic_cast<
const
UintegerValue
*
>
(&value);
62
if
(v == 0)
63
{
64
return
false
;
65
}
66
return
v->
Get
() >= m_minValue && v->
Get
() <= m_maxValue;
67
}
68
virtual
std::string GetValueTypeName (
void
)
const
69
{
70
NS_LOG_FUNCTION_NOARGS
();
71
return
"ns3::UintegerValue"
;
72
}
73
virtual
bool
HasUnderlyingTypeInformation (
void
)
const
74
{
75
NS_LOG_FUNCTION_NOARGS
();
76
return
true
;
77
}
78
virtual
std::string GetUnderlyingTypeInformation (
void
)
const
79
{
80
NS_LOG_FUNCTION_NOARGS
();
81
std::ostringstream oss;
82
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
83
return
oss.str ();
84
}
85
virtual
Ptr<AttributeValue>
Create
(
void
)
const
86
{
87
NS_LOG_FUNCTION_NOARGS
();
88
return
ns3::Create<UintegerValue> ();
89
}
90
virtual
bool
Copy
(
const
AttributeValue
&source,
AttributeValue
&destination)
const
91
{
92
NS_LOG_FUNCTION
(&source << &destination);
93
const
UintegerValue
*src =
dynamic_cast<
const
UintegerValue
*
>
(&source);
94
UintegerValue
*dst =
dynamic_cast<
UintegerValue
*
>
(&destination);
95
if
(src == 0 || dst == 0)
96
{
97
return
false
;
98
}
99
*dst = *src;
100
return
true
;
101
}
102
uint64_t m_minValue;
103
uint64_t m_maxValue;
104
std::string m_name;
105
} *checker =
new
Checker (
min
,
max
, name);
106
return
Ptr<const AttributeChecker>
(checker,
false
);
107
}
108
109
}
// namespace internal
110
111
}
// namespace ns3
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
fatal-error.h
NS_FATAL_x macro definitions.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:69
uinteger.h
ns3::UintegerValue attribute value declarations and template implementations.
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition:
ptr.h:409
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
ns3::min
double min(double x, double y)
Definition:
cobalt-queue-disc.cc:132
ns3::AttributeChecker
Represent the type of an attribute.
Definition:
attribute.h:167
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition:
ptr.h:555
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:209
log.h
Debug message logging.
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type, name)
Define the class methods belonging to the attribute value class nameValue of the underlying class typ...
Definition:
attribute-helper.h:283
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:44
ns3::max
double max(double x, double y)
Definition:
cobalt-queue-disc.cc:137
ns3::UintegerValue::Get
uint64_t Get(void) const
Definition:
uinteger.cc:35
ns3::internal::MakeUintegerChecker
Ptr< const AttributeChecker > MakeUintegerChecker(uint64_t min, uint64_t max, std::string name)
Make an Uinteger attribute checker with embedded numeric type name.
Definition:
uinteger.cc:48
src
core
model
uinteger.cc
Generated on Fri Oct 1 2021 17:02:58 for ns-3 by
1.8.20