A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
integer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef INTEGER_H
9#define INTEGER_H
10
11#include "attribute-helper.h"
12#include "attribute.h"
13
14#include <limits>
15#include <stdint.h>
16
17/**
18 * \file
19 * \ingroup attribute_Integer
20 * ns3::IntegerValue attribute value declarations and template implementations.
21 */
22
23namespace ns3
24{
25
26// Additional docs for class IntegerValue:
27/**
28 * Hold a signed integer type
29 *
30 * This class can be used to hold variables of signed integer
31 * type such as int8_t, int16_t, int32_t, int64_t, or,
32 * int, etc.
33 */
36
37template <typename T>
39
40/**
41 * Make a checker with a minimum value.
42 *
43 * The minimum value is included in the allowed range.
44 *
45 * \param [in] min The minimum value.
46 * \returns The AttributeChecker.
47 * \see AttributeChecker
48 */
49template <typename T>
51
52/**
53 * Make a checker with a minimum and a maximum value.
54 *
55 * The minimum and maximum values are included in the allowed range.
56 *
57 * \param [in] min The minimum value.
58 * \param [in] max The maximum value.
59 * \returns The AttributeChecker.
60 * \see AttributeChecker
61 */
62template <typename T>
63Ptr<const AttributeChecker> MakeIntegerChecker(int64_t min, int64_t max);
64
65} // namespace ns3
66
67/***************************************************************
68 * Implementation of the templates declared above.
69 ***************************************************************/
70
71#include "type-name.h"
72
73namespace ns3
74{
75
76namespace internal
77{
78
79Ptr<const AttributeChecker> MakeIntegerChecker(int64_t min, int64_t max, std::string name);
80
81} // namespace internal
82
83template <typename T>
84Ptr<const AttributeChecker>
85MakeIntegerChecker(int64_t min, int64_t max)
86{
88}
89
90template <typename T>
91Ptr<const AttributeChecker>
93{
94 return internal::MakeIntegerChecker(min, std::numeric_limits<T>::max(), TypeNameGet<T>());
95}
96
97template <typename T>
98Ptr<const AttributeChecker>
100{
101 return internal::MakeIntegerChecker(std::numeric_limits<T>::min(),
102 std::numeric_limits<T>::max(),
104}
105
106} // namespace ns3
107
108#endif /* INTEGER_H */
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Smart pointer class similar to boost::intrusive_ptr.
#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type, name)
Declare the attribute value class nameValue for underlying class type .
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type .
std::string TypeNameGet()
Type name strings for AttributeValue types.
Definition type-name.h:36
Ptr< const AttributeChecker > MakeIntegerChecker(int64_t min, int64_t max, std::string name)
Make an Integer attribute checker with embedded numeric type name.
Definition integer.cc:41
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeIntegerChecker()
Definition integer.h:99
ns3::TypeNameGet() function declarations.