2008-03-10 00:38:48 +01:00
|
|
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2008 INRIA
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
* published by the Free Software Foundation;
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
|
|
|
|
*/
|
2008-02-21 00:09:16 +01:00
|
|
|
#ifndef INTEGER_H
|
|
|
|
|
#define INTEGER_H
|
2008-02-04 22:18:07 +01:00
|
|
|
|
2008-02-20 21:45:42 +01:00
|
|
|
#include "attribute.h"
|
2008-02-21 18:54:02 +01:00
|
|
|
#include "attribute-helper.h"
|
2008-02-04 22:18:07 +01:00
|
|
|
#include <stdint.h>
|
2008-07-02 03:16:36 -07:00
|
|
|
#include <limits>
|
2008-02-04 22:18:07 +01:00
|
|
|
|
|
|
|
|
namespace ns3 {
|
|
|
|
|
|
2008-03-10 14:05:26 -07:00
|
|
|
/**
|
2008-05-29 23:24:10 -07:00
|
|
|
* \ingroup attribute
|
2008-04-17 15:30:18 -07:00
|
|
|
* \class ns3::IntegerValue
|
2008-03-10 14:05:26 -07:00
|
|
|
* \brief Hold a signed integer type
|
|
|
|
|
*
|
2008-04-09 13:03:58 -07:00
|
|
|
* \anchor int8_t
|
|
|
|
|
* \anchor int16_t
|
|
|
|
|
* \anchor int32_t
|
|
|
|
|
* \anchor int64_t
|
|
|
|
|
*
|
2008-03-10 14:05:26 -07:00
|
|
|
* This class can be used to hold variables of signed integer
|
|
|
|
|
* type such as int8_t, int16_t, int32_t, int64_t, or,
|
|
|
|
|
* int, etc.
|
|
|
|
|
*/
|
2008-02-04 22:18:07 +01:00
|
|
|
|
2008-04-17 13:42:25 -07:00
|
|
|
ATTRIBUTE_VALUE_DEFINE_WITH_NAME(int64_t, Integer);
|
2008-02-21 00:09:16 +01:00
|
|
|
ATTRIBUTE_ACCESSOR_DEFINE(Integer);
|
2008-02-18 00:18:45 +01:00
|
|
|
|
|
|
|
|
template <typename T>
|
2008-02-21 00:09:16 +01:00
|
|
|
Ptr<const AttributeChecker> MakeIntegerChecker (void);
|
2008-02-18 00:18:45 +01:00
|
|
|
|
2008-02-26 20:23:43 +01:00
|
|
|
template <typename T>
|
|
|
|
|
Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min);
|
|
|
|
|
|
2008-03-12 11:35:00 -07:00
|
|
|
template <typename T>
|
2008-02-21 00:09:16 +01:00
|
|
|
Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min, int64_t max);
|
2008-02-04 22:18:07 +01:00
|
|
|
|
|
|
|
|
} // namespace ns3
|
|
|
|
|
|
2008-03-12 11:35:00 -07:00
|
|
|
#include "type-name.h"
|
|
|
|
|
|
2008-02-04 22:18:07 +01:00
|
|
|
namespace ns3 {
|
|
|
|
|
|
2008-03-12 11:35:00 -07:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
Ptr<const AttributeChecker> MakeIntegerChecker (int64_t min, int64_t max, std::string name);
|
|
|
|
|
|
|
|
|
|
} // internal
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
Ptr<const AttributeChecker>
|
|
|
|
|
MakeIntegerChecker (int64_t min, int64_t max)
|
|
|
|
|
{
|
|
|
|
|
return internal::MakeIntegerChecker (min,
|
|
|
|
|
max, TypeNameGet<T> ());
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 20:23:43 +01:00
|
|
|
template <typename T>
|
|
|
|
|
Ptr<const AttributeChecker>
|
|
|
|
|
MakeIntegerChecker (int64_t min)
|
|
|
|
|
{
|
2008-03-12 11:35:00 -07:00
|
|
|
return internal::MakeIntegerChecker (min,
|
|
|
|
|
std::numeric_limits<T>::max (),
|
|
|
|
|
TypeNameGet<T> ());
|
2008-02-26 20:23:43 +01:00
|
|
|
}
|
|
|
|
|
|
2008-02-18 00:18:45 +01:00
|
|
|
template <typename T>
|
2008-02-20 20:57:59 +01:00
|
|
|
Ptr<const AttributeChecker>
|
2008-02-21 00:09:16 +01:00
|
|
|
MakeIntegerChecker (void)
|
2008-02-04 22:18:07 +01:00
|
|
|
{
|
2008-03-12 11:35:00 -07:00
|
|
|
return internal::MakeIntegerChecker (std::numeric_limits<T>::min (),
|
|
|
|
|
std::numeric_limits<T>::max (),
|
|
|
|
|
TypeNameGet<T> ());
|
2008-02-04 22:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ns3
|
|
|
|
|
|
2008-02-21 00:09:16 +01:00
|
|
|
#endif /* INTEGER_H */
|