A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
uinteger.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
#include "
uinteger.h
"
20
21
#include "
fatal-error.h
"
22
#include "
log.h
"
23
24
#include <sstream>
25
32
namespace
ns3
33
{
34
35
NS_LOG_COMPONENT_DEFINE
(
"Uinteger"
);
36
37
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(uint64_t, Uinteger);
38
39
namespace
internal
40
{
41
51
Ptr<const AttributeChecker>
52
MakeUintegerChecker
(uint64_t
min
, uint64_t
max
, std::string name)
53
{
54
NS_LOG_FUNCTION
(
min
<<
max
<< name);
55
56
struct
Checker :
public
AttributeChecker
57
{
58
Checker(uint64_t minValue, uint64_t maxValue, std::string name)
59
: m_minValue(minValue),
60
m_maxValue(maxValue),
61
m_name(name)
62
{
63
}
64
65
bool
Check(
const
AttributeValue
& value)
const override
66
{
67
NS_LOG_FUNCTION
(&value);
68
const
UintegerValue
* v =
dynamic_cast<
const
UintegerValue
*
>
(&value);
69
if
(v ==
nullptr
)
70
{
71
return
false
;
72
}
73
return
v->
Get
() >= m_minValue && v->
Get
() <= m_maxValue;
74
}
75
76
std::string GetValueTypeName()
const override
77
{
78
NS_LOG_FUNCTION_NOARGS
();
79
return
"ns3::UintegerValue"
;
80
}
81
82
bool
HasUnderlyingTypeInformation()
const override
83
{
84
NS_LOG_FUNCTION_NOARGS
();
85
return
true
;
86
}
87
88
std::string GetUnderlyingTypeInformation()
const override
89
{
90
NS_LOG_FUNCTION_NOARGS
();
91
std::ostringstream oss;
92
oss << m_name <<
" "
<< m_minValue <<
":"
<< m_maxValue;
93
return
oss.str();
94
}
95
96
Ptr<AttributeValue>
Create
()
const override
97
{
98
NS_LOG_FUNCTION_NOARGS
();
99
return
ns3::Create<UintegerValue>();
100
}
101
102
bool
Copy
(
const
AttributeValue
& source,
AttributeValue
& destination)
const override
103
{
104
NS_LOG_FUNCTION
(&source << &destination);
105
const
UintegerValue
* src =
dynamic_cast<
const
UintegerValue
*
>
(&source);
106
UintegerValue
* dst =
dynamic_cast<
UintegerValue
*
>
(&destination);
107
if
(src ==
nullptr
|| dst ==
nullptr
)
108
{
109
return
false
;
110
}
111
*dst = *src;
112
return
true
;
113
}
114
115
uint64_t m_minValue;
116
uint64_t m_maxValue;
117
std::string m_name;
118
}* checker =
new
Checker(
min
,
max
, name);
119
120
return
Ptr<const AttributeChecker>
(checker,
false
);
121
}
122
123
}
// namespace internal
124
125
}
// namespace ns3
min
#define min(a, b)
Definition:
80211b.c:41
max
#define max(a, b)
Definition:
80211b.c:42
ns3::AttributeChecker
Represent the type of an attribute.
Definition:
attribute.h:168
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:70
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:45
ns3::UintegerValue::Get
uint64_t Get() const
Definition:
uinteger.cc:37
fatal-error.h
NS_FATAL_x macro definitions.
ns3::MakeUintegerChecker
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition:
uinteger.h:96
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:294
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:204
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:238
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:481
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition:
ptr.h:649
uinteger.h
ns3::UintegerValue attribute value declarations and template implementations.
src
core
model
uinteger.cc
Generated on Sun Jul 2 2023 18:21:33 for ns-3 by
1.9.6