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