diff --git a/src/core/random-variable.cc b/src/core/random-variable.cc index 28255ebd9..a09ff357b 100644 --- a/src/core/random-variable.cc +++ b/src/core/random-variable.cc @@ -302,19 +302,20 @@ RandomVariable::Peek (void) const RandomVariable::RandomVariable (Attribute value) : m_variable (0) { - *this = ClassValueHelperExtractFrom (value); + const RandomVariableValue *v = value.DynCast (); + if (v == 0) + { + NS_FATAL_ERROR ("Unexpected type of value. Expected \"RandomVariableValue\""); + } + *this = v->Get (); } RandomVariable::operator Attribute () const { - return ClassValueHelperConvertTo (this); -} - -Ptr -MakeRandomVariableChecker (void) -{ - return MakeSimpleAttributeChecker (); + return Attribute::Create (*this); } +ATTRIBUTE_VALUE_IMPLEMENT (RandomVariable); +ATTRIBUTE_CHECKER_IMPLEMENT (RandomVariable); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/src/core/random-variable.h b/src/core/random-variable.h index 939680ba7..ace5a048b 100644 --- a/src/core/random-variable.h +++ b/src/core/random-variable.h @@ -27,7 +27,7 @@ #include #include #include "attribute.h" -#include "class-value-helper.h" +#include "value-helper.h" /** * \ingroup core @@ -168,7 +168,6 @@ public: operator Attribute () const; private: - friend class RandomVariableValue; friend std::ostream &operator << (std::ostream &os, const RandomVariable &var); friend std::istream &operator >> (std::istream &os, RandomVariable &var); @@ -664,36 +663,11 @@ public: std::ostream &operator << (std::ostream &os, const RandomVariable &var); std::istream &operator >> (std::istream &os, RandomVariable &var); - -class RandomVariableValue : public AttributeValue {}; -class RandomVariableAccessor : public AttributeAccessor {}; - -template -Ptr MakeRandomVariableAccessor (T1 a1); -template -Ptr MakeRandomVariableAccessor (T1 a1, T2 a2); - -Ptr MakeRandomVariableChecker (void); +ATTRIBUTE_VALUE_DEFINE (RandomVariable); +ATTRIBUTE_CHECKER_DEFINE (RandomVariable); +ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable); }//namespace ns3 -namespace ns3 { - -template -Ptr MakeRandomVariableAccessor (T1 a1) -{ - return MakeClassValueHelperAccessor (a1); -} - -template -Ptr MakeRandomVariableAccessor (T1 a1, T2 a2) -{ - return MakeClassValueHelperAccessor (a1, a2); -} - - -} // namespace ns3 #endif