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 #ifndef UINTEGER_H
21 #define UINTEGER_H
22
23 #include "attribute.h"
24 #include "attribute-helper.h"
25 #include <stdint.h>
26 #include <limits>
27
28 /**
29 * \file
30 * \ingroup attribute_Uinteger
31 * ns3::UintegerValue attribute value declarations and template implementations.
32 */
33
34 namespace ns3 {
35
36 // Additional docs for class UintegerValue:
37 /**
38 * Hold an unsigned integer type.
39 *
40 * This class can be used to hold variables of unsigned integer
41 * type such as uint8_t, uint16_t, uint32_t, uint64_t, or,
42 * unsigned int, etc.
43 */
44 ATTRIBUTE_VALUE_DEFINE_WITH_NAME (uint64_t, Uinteger);
45 ATTRIBUTE_ACCESSOR_DEFINE (Uinteger);
46
47 template <typename T>
48 Ptr<const AttributeChecker> MakeUintegerChecker (void);
49
50 /**
51 * Make a checker with a minimum value.
52 *
53 * The minimum value is included in the allowed range.
54 *
55 * \param [in] min The minimum value.
56 * \returns The AttributeChecker.
57 * \see AttributeChecker
58 */
59 template <typename T>
60 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min);
61
62 /**
63 * Make a checker with a minimum and a maximum value.
64 *
65 * The minimum and maximum values are included in the allowed range.
66 *
67 * \param [in] min The minimum value.
68 * \param [in] max The maximum value.
69 * \returns The AttributeChecker.
70 * \see AttributeChecker
71 */
72 template <typename T>
73 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max);
74
75 } // namespace ns3
76
77
78 /***************************************************************
79 * Implementation of the templates declared above.
80 ***************************************************************/
81
82 #include "type-name.h"
83
84 namespace ns3 {
85
86 namespace internal {
87
88 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max, std::string name);
89
90 } // namespace internal
91
92
93 template <typename T>
MakeUintegerChecker(void)94 Ptr<const AttributeChecker> MakeUintegerChecker (void)
95 {
96 return internal::MakeUintegerChecker (std::numeric_limits<T>::min (),
97 std::numeric_limits<T>::max (),
98 TypeNameGet<T> ());
99 }
100
101 template <typename T>
MakeUintegerChecker(uint64_t min)102 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min)
103 {
104 return internal::MakeUintegerChecker (min,
105 std::numeric_limits<T>::max (),
106 TypeNameGet<T> ());
107 }
108
109 template <typename T>
MakeUintegerChecker(uint64_t min,uint64_t max)110 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max)
111 {
112 return internal::MakeUintegerChecker (min,
113 max,
114 TypeNameGet<T> ());
115 }
116
117 } // namespace ns3
118
119 #endif /* UINTEGER_H */
120