src/core/random-variable.h
changeset 2384 500ada6a4874
parent 2383 a0e0ec096169
child 2408 04fe819b3ad1
--- a/src/core/random-variable.h	Thu Feb 07 19:57:21 2008 +0100
+++ b/src/core/random-variable.h	Thu Feb 07 22:40:46 2008 +0100
@@ -24,6 +24,7 @@
 #include <vector>
 #include <algorithm>
 #include <stdint.h>
+#include "value.h"
 
 /**
  * \ingroup core
@@ -158,11 +159,17 @@
    * \endcode
    */
   static void SetRunNumber(uint32_t n);
+
+
+  RandomVariable (PValue value);
+  operator PValue () const;
+
 private:
+  friend class RandomVariableValue;
   RandomVariableBase *m_variable;
 protected:
   RandomVariable (const RandomVariableBase &variable);
-  RandomVariableBase *Peek (void);
+  RandomVariableBase *Peek (void) const;
 };
 
 /**
@@ -648,5 +655,39 @@
   static double GetSingleValue(double s, double l, double mean);
 };
 
+
+class RandomVariableValue : public Value
+{
+public:
+  RandomVariableValue (RandomVariable variable);
+  void Set (RandomVariable variable);
+  RandomVariable Get (void) const;
+
+  virtual PValue Copy (void) const;
+  virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
+  virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+
+  RandomVariableValue (PValue value);
+  operator PValue () const;
+private:
+  RandomVariable m_variable;
+};
+
+template <typename T>
+Ptr<ParamSpec> MakeRandomVariableParamSpec (RandomVariable T::*m_memberVariable,
+                                            RandomVariable initialValue);
+
 }//namespace ns3
+
+
+namespace ns3 {
+
+template <typename T>
+Ptr<ParamSpec> MakeRandomVariableParamSpec (RandomVariable T::*memberVariable,
+                                            RandomVariable initialValue)
+{
+  return MakeMemberVariableParamSpec (memberVariable, RandomVariableValue (initialValue));
+}
+
+} // namespace ns3
 #endif