src/core/integer.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 INTEGER_H
    21 #define INTEGER_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  * \class ns3::IntegerValue
    33  * \brief Hold a signed integer type
    34  *
    35  * \anchor int8_t
    36  * \anchor int16_t
    37  * \anchor int32_t
    38  * \anchor int64_t
    39  *
    40  * This class can be used to hold variables of signed integer
    41  * type such as int8_t, int16_t, int32_t, int64_t, or,
    42  * int, etc.
    43  */
    44 
    45 ATTRIBUTE_VALUE_DEFINE_WITH_NAME(int64_t, Integer);
    46 ATTRIBUTE_ACCESSOR_DEFINE(Integer);
    47 
    48 template <typename T>
    49 Ptr<const AttributeChecker> MakeIntegerChecker (void);
    50 
    51 template <typename T>
    52 Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min);
    53 
    54 template <typename T>
    55 Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min, int64_t max);
    56 
    57 } // namespace ns3
    58 
    59 #include "type-name.h"
    60 
    61 namespace ns3 {
    62 
    63 namespace internal {
    64 
    65 Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min, int64_t max, std::string name);
    66 
    67 } // internal
    68 
    69 template <typename T>
    70 Ptr<const AttributeChecker>
    71 MakeIntegerChecker (int64_t min, int64_t max)
    72 {
    73   return internal::MakeIntegerChecker (min,
    74                                        max, TypeNameGet<T> ());
    75 }
    76 
    77 template <typename T>
    78 Ptr<const AttributeChecker>
    79 MakeIntegerChecker (int64_t min)
    80 {
    81   return internal::MakeIntegerChecker (min,
    82                                        std::numeric_limits<T>::max (),
    83                                        TypeNameGet<T> ());
    84 }
    85 
    86 template <typename T>
    87 Ptr<const AttributeChecker>
    88 MakeIntegerChecker (void)
    89 {
    90   return internal::MakeIntegerChecker (std::numeric_limits<T>::min (),
    91                                        std::numeric_limits<T>::max (),
    92                                        TypeNameGet<T> ());
    93 }
    94 
    95 } // namespace ns3
    96 
    97 #endif /* INTEGER_H */