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
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@2439
    20
#ifndef UINTEGER_H
mathieu@2439
    21
#define UINTEGER_H
mathieu@2379
    22
mathieu@2438
    23
#include "attribute.h"
mathieu@2451
    24
#include "attribute-helper.h"
mathieu@2379
    25
#include <stdint.h>
mathieu@3365
    26
#include <limits>
mathieu@2379
    27
mathieu@2379
    28
namespace ns3 {
mathieu@2379
    29
mathieu@2584
    30
/**
tomh@3182
    31
 * \ingroup attribute
tomh@3182
    32
 *
mathieu@2968
    33
 * \class ns3::UintegerValue
mathieu@2584
    34
 * \brief Hold an unsigned integer type
mathieu@2584
    35
 *
mathieu@2928
    36
 * \anchor uint8_t
mathieu@2928
    37
 * \anchor uint16_t
mathieu@2928
    38
 * \anchor uint32_t
mathieu@2928
    39
 * \anchor uint64_t
mathieu@2928
    40
 *
mathieu@2584
    41
 * This class can be used to hold variables of unsigned integer
mathieu@2584
    42
 * type such as uint8_t, uint16_t, uint32_t, uint64_t, or,
mathieu@2584
    43
 * unsigned int, etc.
mathieu@2584
    44
 */
mathieu@2379
    45
mathieu@2965
    46
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (uint64_t, Uinteger);
mathieu@2439
    47
ATTRIBUTE_ACCESSOR_DEFINE (Uinteger);
mathieu@2427
    48
mathieu@2427
    49
template <typename T>
mathieu@2439
    50
Ptr<const AttributeChecker> MakeUintegerChecker (void);
mathieu@2428
    51
mathieu@2485
    52
template <typename T>
mathieu@2485
    53
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min);
mathieu@2485
    54
mathieu@2599
    55
template <typename T>
mathieu@2439
    56
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max);
mathieu@2379
    57
mathieu@2379
    58
} // namespace ns3
mathieu@2379
    59
mathieu@2599
    60
#include "type-name.h"
mathieu@2599
    61
mathieu@2379
    62
namespace ns3 {
mathieu@2379
    63
mathieu@2599
    64
namespace internal {
mathieu@2599
    65
mathieu@2599
    66
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max, std::string name);
mathieu@2599
    67
mathieu@2599
    68
} // namespace internal
mathieu@2599
    69
mathieu@2599
    70
mathieu@2439
    71
template <typename T>
mathieu@2439
    72
Ptr<const AttributeChecker> MakeUintegerChecker (void)
mathieu@2379
    73
{
mathieu@2599
    74
  return internal::MakeUintegerChecker (std::numeric_limits<T>::min (),
mathieu@2599
    75
                                        std::numeric_limits<T>::max (),
mathieu@2599
    76
                                        TypeNameGet<T> ());
mathieu@2427
    77
}
mathieu@2379
    78
mathieu@2485
    79
template <typename T>
mathieu@2485
    80
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min)
mathieu@2485
    81
{
mathieu@2599
    82
  return internal::MakeUintegerChecker (min,
mathieu@2599
    83
                                        std::numeric_limits<T>::max (),
mathieu@2599
    84
                                        TypeNameGet<T> ());
mathieu@2599
    85
}
mathieu@2599
    86
mathieu@2599
    87
template <typename T>
mathieu@2599
    88
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max)
mathieu@2599
    89
{
mathieu@2599
    90
  return internal::MakeUintegerChecker (min,
mathieu@2599
    91
                                        max, 
mathieu@2599
    92
                                        TypeNameGet<T> ());
mathieu@2485
    93
}
mathieu@2485
    94
mathieu@2379
    95
} // namespace ns3
mathieu@2379
    96
mathieu@2439
    97
#endif /* UINTEGER_H */