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