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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef NS_DOUBLE_H
9#define NS_DOUBLE_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_Double
20 * ns3::DoubleValue attribute value declarations and template implementations.
21 */
22
23namespace ns3
24{
25
26// Additional docs for class DoubleValue:
27/**
28 * This class can be used to hold variables of floating point type
29 * such as 'double' or 'float'. The internal format is 'double'.
30 */
33
34template <typename T>
36
37/**
38 * Make a checker with a minimum value.
39 *
40 * The minimum value is included in the allowed range.
41 *
42 * \param [in] min The minimum value.
43 * \returns The AttributeChecker.
44 * \see AttributeChecker
45 */
46template <typename T>
48
49/**
50 * Make a checker with a minimum and a maximum value.
51 *
52 * The minimum and maximum values are included in the allowed range.
53 *
54 * \param [in] min The minimum value.
55 * \param [in] max The maximum value.
56 * \returns The AttributeChecker.
57 * \see AttributeChecker
58 */
59template <typename T>
61
62} // namespace ns3
63
64/***************************************************************
65 * Implementation of the templates declared above.
66 ***************************************************************/
67
68#include "type-name.h"
69
70namespace ns3
71{
72
73namespace internal
74{
75
76Ptr<const AttributeChecker> MakeDoubleChecker(double min, double max, std::string name);
77
78} // namespace internal
79
80template <typename T>
81Ptr<const AttributeChecker>
83{
84 return internal::MakeDoubleChecker(-std::numeric_limits<T>::max(),
85 std::numeric_limits<T>::max(),
87}
88
89template <typename T>
90Ptr<const AttributeChecker>
92{
93 return internal::MakeDoubleChecker(min, std::numeric_limits<T>::max(), TypeNameGet<T>());
94}
95
96template <typename T>
97Ptr<const AttributeChecker>
98MakeDoubleChecker(double min, double max)
99{
101}
102
103} // namespace ns3
104
105#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.
#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 > MakeDoubleChecker(double min, double max, std::string name)
Make a Double attribute checker with embedded numeric type name.
Definition double.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
ns3::TypeNameGet() function declarations.