src/core/double.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 3182 61fe7fe81ebd
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
mathieu@2581
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
mathieu@2581
     2
/*
mathieu@2581
     3
 * Copyright (c) 2008 INRIA
mathieu@2581
     4
 *
mathieu@2581
     5
 * This program is free software; you can redistribute it and/or modify
mathieu@2581
     6
 * it under the terms of the GNU General Public License version 2 as
mathieu@2581
     7
 * published by the Free Software Foundation;
mathieu@2581
     8
 *
mathieu@2581
     9
 * This program is distributed in the hope that it will be useful,
mathieu@2581
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mathieu@2581
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mathieu@2581
    12
 * GNU General Public License for more details.
mathieu@2581
    13
 *
mathieu@2581
    14
 * You should have received a copy of the GNU General Public License
mathieu@2581
    15
 * along with this program; if not, write to the Free Software
mathieu@2581
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mathieu@2581
    17
 *
mathieu@2581
    18
 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
mathieu@2581
    19
 */
mathieu@2581
    20
#ifndef NS_DOUBLE_H
mathieu@2581
    21
#define NS_DOUBLE_H
mathieu@2385
    22
mathieu@2438
    23
#include "attribute.h"
mathieu@2451
    24
#include "attribute-helper.h"
mathieu@2385
    25
#include <stdint.h>
mathieu@3365
    26
#include <limits>
mathieu@2385
    27
mathieu@2385
    28
namespace ns3 {
mathieu@2385
    29
mathieu@2584
    30
/**
tomh@3182
    31
 * \ingroup attribute 
tomh@3182
    32
 *
mathieu@2969
    33
 * \class ns3::DoubleValue
mathieu@2584
    34
 * \brief Hold an floating point type
mathieu@2584
    35
 *
mathieu@2928
    36
 * \anchor double
mathieu@2584
    37
 * This class can be used to hold variables of floating point type
mathieu@2584
    38
 * such as 'double' or 'float'. The internal format is 'double'.
mathieu@2584
    39
 */
mathieu@2385
    40
mathieu@2965
    41
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (double, Double);
mathieu@2444
    42
ATTRIBUTE_ACCESSOR_DEFINE (Double);
mathieu@2427
    43
mathieu@2427
    44
template <typename T>
mathieu@2444
    45
Ptr<const AttributeChecker> MakeDoubleChecker (void);
mathieu@2428
    46
mathieu@2487
    47
template <typename T>
mathieu@2487
    48
Ptr<const AttributeChecker> MakeDoubleChecker (double min);
mathieu@2487
    49
mathieu@2599
    50
template <typename T>
mathieu@2444
    51
Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max);
mathieu@2427
    52
mathieu@2385
    53
mathieu@2385
    54
} // namespace ns3
mathieu@2385
    55
mathieu@2599
    56
#include "type-name.h"
mathieu@2599
    57
mathieu@2385
    58
namespace ns3 {
mathieu@2385
    59
mathieu@2599
    60
namespace internal {
mathieu@2599
    61
mathieu@2599
    62
Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max, std::string name);
mathieu@2599
    63
mathieu@2599
    64
} // namespace internal
mathieu@2599
    65
mathieu@2444
    66
template <typename T>
mathieu@2444
    67
Ptr<const AttributeChecker> MakeDoubleChecker (void)
mathieu@2385
    68
{
mathieu@2599
    69
  return internal::MakeDoubleChecker (-std::numeric_limits<T>::max (),
mathieu@2599
    70
                                      std::numeric_limits<T>::max (),
mathieu@2599
    71
                                      TypeNameGet<T> ());
mathieu@2385
    72
}
mathieu@2385
    73
mathieu@2487
    74
template <typename T>
mathieu@2487
    75
Ptr<const AttributeChecker> MakeDoubleChecker (double min)
mathieu@2487
    76
{
mathieu@2599
    77
  return internal::MakeDoubleChecker (min,
mathieu@2599
    78
                                      std::numeric_limits<T>::max (),
mathieu@2599
    79
                                      TypeNameGet<T> ());
mathieu@2599
    80
}
mathieu@2599
    81
mathieu@2599
    82
template <typename T>
mathieu@2599
    83
Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max)
mathieu@2599
    84
{
mathieu@2599
    85
  return internal::MakeDoubleChecker (min,
mathieu@2599
    86
                                      max,
mathieu@2599
    87
                                      TypeNameGet<T> ());
mathieu@2487
    88
}
mathieu@2487
    89
mathieu@2385
    90
} // namespace ns3
mathieu@2385
    91
mathieu@2581
    92
#endif /* NS_DOUBLE_H */