convert RandomVariable to new helpers.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 21 Feb 2008 18:28:05 +0100
changeset 2445 e1b65471f159
parent 2444 74fb004db27c
child 2446 f2a03c7d069c
convert RandomVariable to new helpers.
src/core/random-variable.cc
src/core/random-variable.h
--- a/src/core/random-variable.cc	Thu Feb 21 00:54:05 2008 +0100
+++ b/src/core/random-variable.cc	Thu Feb 21 18:28:05 2008 +0100
@@ -302,19 +302,20 @@
 RandomVariable::RandomVariable (Attribute value)
   : m_variable (0)
 {
-  *this = ClassValueHelperExtractFrom<RandomVariable,RandomVariableValue> (value);
+  const RandomVariableValue *v = value.DynCast<const RandomVariableValue *> ();
+  if (v == 0)
+    {
+      NS_FATAL_ERROR ("Unexpected type of value. Expected \"RandomVariableValue\"");
+    }
+  *this = v->Get ();
 }
 RandomVariable::operator Attribute () const
 {
-  return ClassValueHelperConvertTo<RandomVariable,RandomVariableValue> (this);
+  return Attribute::Create<RandomVariableValue> (*this);
 }
 
-Ptr<const AttributeChecker> 
-MakeRandomVariableChecker (void)
-{
-  return MakeSimpleAttributeChecker<RandomVariableValue> ();
-}
-
+ATTRIBUTE_VALUE_IMPLEMENT (RandomVariable);
+ATTRIBUTE_CHECKER_IMPLEMENT (RandomVariable);
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
--- a/src/core/random-variable.h	Thu Feb 21 00:54:05 2008 +0100
+++ b/src/core/random-variable.h	Thu Feb 21 18:28:05 2008 +0100
@@ -27,7 +27,7 @@
 #include <istream>
 #include <ostream>
 #include "attribute.h"
-#include "class-value-helper.h"
+#include "value-helper.h"
 
 /**
  * \ingroup core
@@ -168,7 +168,6 @@
   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 @@
 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 <typename T1>
-Ptr<const AttributeAccessor> MakeRandomVariableAccessor (T1 a1);
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeRandomVariableAccessor (T1 a1, T2 a2);
-
-Ptr<const AttributeChecker> MakeRandomVariableChecker (void);
+ATTRIBUTE_VALUE_DEFINE (RandomVariable);
+ATTRIBUTE_CHECKER_DEFINE (RandomVariable);
+ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable);
 
 }//namespace ns3
 
 
-namespace ns3 {
-
-template <typename T1>
-Ptr<const AttributeAccessor> MakeRandomVariableAccessor (T1 a1)
-{
-  return MakeClassValueHelperAccessor<RandomVariable, 
-    RandomVariableValue, RandomVariableAccessor> (a1);
-}
-
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeRandomVariableAccessor (T1 a1, T2 a2)
-{
-  return MakeClassValueHelperAccessor<RandomVariable, 
-    RandomVariableValue,RandomVariableAccessor> (a1, a2);
-}
-
-
-} // namespace ns3
 #endif