00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "uinteger.h"
00021 #include "fatal-error.h"
00022 #include <sstream>
00023
00024 namespace ns3 {
00025
00026 ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(uint64_t,Uinteger);
00027
00028 namespace internal {
00029
00030 Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max, std::string name)
00031 {
00032 struct Checker : public AttributeChecker
00033 {
00034 Checker (uint64_t minValue, uint64_t maxValue, std::string name)
00035 : m_minValue (minValue),
00036 m_maxValue (maxValue),
00037 m_name (name) {}
00038 virtual bool Check (const AttributeValue &value) const {
00039 const UintegerValue *v = dynamic_cast<const UintegerValue *> (&value);
00040 if (v == 0)
00041 {
00042 return false;
00043 }
00044 return v->Get () >= m_minValue && v->Get () <= m_maxValue;
00045 }
00046 virtual std::string GetValueTypeName (void) const {
00047 return "ns3::UintegerValue";
00048 }
00049 virtual bool HasUnderlyingTypeInformation (void) const {
00050 return true;
00051 }
00052 virtual std::string GetUnderlyingTypeInformation (void) const {
00053 std::ostringstream oss;
00054 oss << m_name << " " << m_minValue << ":" << m_maxValue;
00055 return oss.str ();
00056 }
00057 virtual Ptr<AttributeValue> Create (void) const {
00058 return ns3::Create<UintegerValue> ();
00059 }
00060 virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
00061 const UintegerValue *src = dynamic_cast<const UintegerValue *> (&source);
00062 UintegerValue *dst = dynamic_cast<UintegerValue *> (&destination);
00063 if (src == 0 || dst == 0)
00064 {
00065 return false;
00066 }
00067 *dst = *src;
00068 return true;
00069 }
00070 uint64_t m_minValue;
00071 uint64_t m_maxValue;
00072 std::string m_name;
00073 } *checker = new Checker (min, max, name);
00074 return Ptr<const AttributeChecker> (checker, false);
00075 }
00076
00077 }
00078
00079 }