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
     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 NS_DOUBLE_H
    21 #define NS_DOUBLE_H
    22 
    23 #include "attribute.h"
    24 #include "attribute-helper.h"
    25 #include <stdint.h>
    26 #include <limits>
    27 
    28 namespace ns3 {
    29 
    30 /**
    31  * \ingroup attribute 
    32  *
    33  * \class ns3::DoubleValue
    34  * \brief Hold an floating point type
    35  *
    36  * \anchor double
    37  * This class can be used to hold variables of floating point type
    38  * such as 'double' or 'float'. The internal format is 'double'.
    39  */
    40 
    41 ATTRIBUTE_VALUE_DEFINE_WITH_NAME (double, Double);
    42 ATTRIBUTE_ACCESSOR_DEFINE (Double);
    43 
    44 template <typename T>
    45 Ptr<const AttributeChecker> MakeDoubleChecker (void);
    46 
    47 template <typename T>
    48 Ptr<const AttributeChecker> MakeDoubleChecker (double min);
    49 
    50 template <typename T>
    51 Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max);
    52 
    53 
    54 } // namespace ns3
    55 
    56 #include "type-name.h"
    57 
    58 namespace ns3 {
    59 
    60 namespace internal {
    61 
    62 Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max, std::string name);
    63 
    64 } // namespace internal
    65 
    66 template <typename T>
    67 Ptr<const AttributeChecker> MakeDoubleChecker (void)
    68 {
    69   return internal::MakeDoubleChecker (-std::numeric_limits<T>::max (),
    70                                       std::numeric_limits<T>::max (),
    71                                       TypeNameGet<T> ());
    72 }
    73 
    74 template <typename T>
    75 Ptr<const AttributeChecker> MakeDoubleChecker (double min)
    76 {
    77   return internal::MakeDoubleChecker (min,
    78                                       std::numeric_limits<T>::max (),
    79                                       TypeNameGet<T> ());
    80 }
    81 
    82 template <typename T>
    83 Ptr<const AttributeChecker> MakeDoubleChecker (double min, double max)
    84 {
    85   return internal::MakeDoubleChecker (min,
    86                                       max,
    87                                       TypeNameGet<T> ());
    88 }
    89 
    90 } // namespace ns3
    91 
    92 #endif /* NS_DOUBLE_H */