src/core/model/integer.cc
changeset 9134 7a750f032acd
parent 7169 358f71a624d8
child 10968 2d29fee2b7b8
equal deleted inserted replaced
9133:bcf7cef191c1 9134:7a750f032acd
    17  *
    17  *
    18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    19  */
    19  */
    20 #include "integer.h"
    20 #include "integer.h"
    21 #include "fatal-error.h"
    21 #include "fatal-error.h"
       
    22 #include "log.h"
    22 #include <sstream>
    23 #include <sstream>
       
    24 
       
    25 NS_LOG_COMPONENT_DEFINE ("Integer");
    23 
    26 
    24 namespace ns3 {
    27 namespace ns3 {
    25 
    28 
    26 ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (int64_t, Integer);
    29 ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (int64_t, Integer);
    27 
    30 
    28 namespace internal {
    31 namespace internal {
    29 
    32 
    30 Ptr<const AttributeChecker>
    33 Ptr<const AttributeChecker>
    31 MakeIntegerChecker (int64_t min, int64_t max, std::string name)
    34 MakeIntegerChecker (int64_t min, int64_t max, std::string name)
    32 {
    35 {
       
    36   NS_LOG_FUNCTION (min << max << name);
    33   struct IntegerChecker : public AttributeChecker
    37   struct IntegerChecker : public AttributeChecker
    34   {
    38   {
    35     IntegerChecker (int64_t minValue, int64_t maxValue, std::string name)
    39     IntegerChecker (int64_t minValue, int64_t maxValue, std::string name)
    36       : m_minValue (minValue),
    40       : m_minValue (minValue),
    37         m_maxValue (maxValue),
    41         m_maxValue (maxValue),
    38         m_name (name) {}
    42         m_name (name) {}
    39     virtual bool Check (const AttributeValue &value) const {
    43     virtual bool Check (const AttributeValue &value) const {
       
    44       NS_LOG_FUNCTION (&value);
    40       const IntegerValue *v = dynamic_cast<const IntegerValue *> (&value);
    45       const IntegerValue *v = dynamic_cast<const IntegerValue *> (&value);
    41       if (v == 0)
    46       if (v == 0)
    42         {
    47         {
    43           return false;
    48           return false;
    44         }
    49         }
    45       return v->Get () >= m_minValue && v->Get () <= m_maxValue;
    50       return v->Get () >= m_minValue && v->Get () <= m_maxValue;
    46     }
    51     }
    47     virtual std::string GetValueTypeName (void) const {
    52     virtual std::string GetValueTypeName (void) const {
       
    53       NS_LOG_FUNCTION_NOARGS ();
    48       return "ns3::IntegerValue";
    54       return "ns3::IntegerValue";
    49     }
    55     }
    50     virtual bool HasUnderlyingTypeInformation (void) const {
    56     virtual bool HasUnderlyingTypeInformation (void) const {
       
    57       NS_LOG_FUNCTION_NOARGS ();
    51       return true;
    58       return true;
    52     }
    59     }
    53     virtual std::string GetUnderlyingTypeInformation (void) const {
    60     virtual std::string GetUnderlyingTypeInformation (void) const {
       
    61       NS_LOG_FUNCTION_NOARGS ();
    54       std::ostringstream oss;
    62       std::ostringstream oss;
    55       oss << m_name << " " << m_minValue << ":" << m_maxValue;
    63       oss << m_name << " " << m_minValue << ":" << m_maxValue;
    56       return oss.str ();
    64       return oss.str ();
    57     }
    65     }
    58     virtual Ptr<AttributeValue> Create (void) const {
    66     virtual Ptr<AttributeValue> Create (void) const {
       
    67       NS_LOG_FUNCTION_NOARGS ();
    59       return ns3::Create<IntegerValue> ();
    68       return ns3::Create<IntegerValue> ();
    60     }
    69     }
    61     virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const {
    70     virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const {
       
    71       NS_LOG_FUNCTION (&src << &dst);
    62       const IntegerValue *source = dynamic_cast<const IntegerValue *> (&src);
    72       const IntegerValue *source = dynamic_cast<const IntegerValue *> (&src);
    63       IntegerValue *destination = dynamic_cast<IntegerValue *> (&dst);
    73       IntegerValue *destination = dynamic_cast<IntegerValue *> (&dst);
    64       if (source == 0 || destination == 0)
    74       if (source == 0 || destination == 0)
    65         {
    75         {
    66           return false;
    76           return false;