A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
double.h
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#ifndef NS_DOUBLE_H
20#define NS_DOUBLE_H
21
22#include "attribute-helper.h"
23#include "attribute.h"
24
25#include <limits>
26#include <stdint.h>
27
28/**
29 * \file
30 * \ingroup attribute_Double
31 * ns3::DoubleValue attribute value declarations and template implementations.
32 */
33
34namespace ns3
35{
36
37// Additional docs for class DoubleValue:
38/**
39 * This class can be used to hold variables of floating point type
40 * such as 'double' or 'float'. The internal format is 'double'.
41 */
44
45template <typename T>
47
48/**
49 * Make a checker with a minimum value.
50 *
51 * The minimum value is included in the allowed range.
52 *
53 * \param [in] min The minimum value.
54 * \returns The AttributeChecker.
55 * \see AttributeChecker
56 */
57template <typename T>
59
60/**
61 * Make a checker with a minimum and a maximum value.
62 *
63 * The minimum and maximum values are included in the allowed range.
64 *
65 * \param [in] min The minimum value.
66 * \param [in] max The maximum value.
67 * \returns The AttributeChecker.
68 * \see AttributeChecker
69 */
70template <typename T>
72
73} // namespace ns3
74
75/***************************************************************
76 * Implementation of the templates declared above.
77 ***************************************************************/
78
79#include "type-name.h"
80
81namespace ns3
82{
83
84namespace internal
85{
86
87Ptr<const AttributeChecker> MakeDoubleChecker(double min, double max, std::string name);
88
89} // namespace internal
90
91template <typename T>
92Ptr<const AttributeChecker>
94{
95 return internal::MakeDoubleChecker(-std::numeric_limits<T>::max(),
96 std::numeric_limits<T>::max(),
97 TypeNameGet<T>());
98}
99
100template <typename T>
101Ptr<const AttributeChecker>
103{
104 return internal::MakeDoubleChecker(min, std::numeric_limits<T>::max(), TypeNameGet<T>());
105}
106
107template <typename T>
108Ptr<const AttributeChecker>
109MakeDoubleChecker(double min, double max)
110{
111 return internal::MakeDoubleChecker(min, max, TypeNameGet<T>());
112}
113
114} // namespace ns3
115
116#endif /* NS_DOUBLE_H */
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Ptr< const AttributeChecker > MakeDoubleChecker(double min, double max, std::string name)
Make a Double attribute checker with embedded numeric type name.
Definition: double.cc:53
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition: double.h:93
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TypeNameGet() function declarations.