--- a/src/core/random-variable.cc Sun Apr 01 15:53:58 2007 +0200
+++ b/src/core/random-variable.cc Tue Apr 03 10:24:18 2007 -0400
@@ -37,54 +37,7 @@
using namespace std;
namespace ns3{
-// Seed methods
-Seed::~Seed()
-{
-}
-
-RandomSeed::RandomSeed()
-{
-}
-
-RandomSeed::~RandomSeed()
-{
-}
-
-bool RandomSeed::IsRandom() const
-{
- return true;
-}
-
-ConstantSeed::~ConstantSeed()
-{
-}
-
-bool ConstantSeed::IsRandom() const
-{
- return false;
-}
-
-ConstantSeed::ConstantSeed(uint32_t s)
-{
- seeds[0] = s;
- seeds[1] = s;
- seeds[2] = s;
- seeds[3] = s;
- seeds[4] = s;
- seeds[5] = s;
-}
-
-ConstantSeed::ConstantSeed(uint32_t s0, uint32_t s1, uint32_t s2,
- uint32_t s3, uint32_t s4, uint32_t s5)
-{
- seeds[0] = s0;
- seeds[1] = s1;
- seeds[2] = s2;
- seeds[3] = s3;
- seeds[4] = s4;
- seeds[5] = s5;
-}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// RandomVariable methods
@@ -133,7 +86,8 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// RandomVariable static methods
-void RandomVariable::UseGlobalSeed(const Seed& s)
+void RandomVariable::UseGlobalSeed(uint32_t s0, uint32_t s1, uint32_t s2,
+ uint32_t s3, uint32_t s4, uint32_t s5)
{
if (RandomVariable::globalSeedSet)
{
@@ -141,16 +95,14 @@
cout << "Call to RandomVariable::UseGlobalSeed() ignored" << endl;
return;
}
- if (s.IsRandom()) return; // Random seed is the default
- const ConstantSeed& cs = (ConstantSeed&)s;
- RandomVariable::globalSeed[0] = cs.seeds[0];
- RandomVariable::globalSeed[1] = cs.seeds[1];
- RandomVariable::globalSeed[2] = cs.seeds[2];
- RandomVariable::globalSeed[3] = cs.seeds[3];
- RandomVariable::globalSeed[4] = cs.seeds[4];
- RandomVariable::globalSeed[5] = cs.seeds[5];
+ RandomVariable::globalSeed[0] = s0;
+ RandomVariable::globalSeed[1] = s1;
+ RandomVariable::globalSeed[2] = s2;
+ RandomVariable::globalSeed[3] = s3;
+ RandomVariable::globalSeed[4] = s4;
+ RandomVariable::globalSeed[5] = s5;
if (!RngStream::CheckSeed(RandomVariable::globalSeed))
- NS_FATAL_ERROR("Invalid seed");
+ NS_FATAL_ERROR("Invalid seed");
RandomVariable::globalSeedSet = true;
}
--- a/src/core/random-variable.h Sun Apr 01 15:53:58 2007 +0200
+++ b/src/core/random-variable.h Tue Apr 03 10:24:18 2007 -0400
@@ -35,41 +35,6 @@
class RngStream;
/**
- * \brief Pure virtual base class for RNG seeds
- */
-class Seed {
- // Seed is used to seed the random number generator(s)
- // This is a base class for RandomSeed and ConstantSeed
-public:
- virtual ~Seed();
- virtual bool IsRandom() const = 0;
-};
-
-/**
- * \brief random RNG seeds
- */
-class RandomSeed : public Seed {
-public:
- RandomSeed();
- ~RandomSeed();
- bool IsRandom() const;
-};
-
-/**
- * \brief constant RNG seeds
- */
-class ConstantSeed : public Seed
-{
-public:
- ConstantSeed(uint32_t); // Use six copies of the specified value
- ConstantSeed(uint32_t,uint32_t,uint32_t,uint32_t,uint32_t,uint32_t); // Six seeds
- bool IsRandom() const;
- ~ConstantSeed();
-public:
- uint32_t seeds[6];
-};
-
-/**
* \brief The basic RNG for NS-3.
* \ingroup randomvariable
*
@@ -164,10 +129,16 @@
* UniformVariable x(2,3); //these will give the same output everytime
* ExponentialVariable y(120); //as long as the seed stays the same
* \endcode
- * \param s
+ * \param s0
+ * \param s1
+ * \param s2
+ * \param s3
+ * \param s4
+ * \param s5
* \return True if seed is valid.
*/
- static void UseGlobalSeed(const Seed& s);
+ static void UseGlobalSeed(uint32_t s0, uint32_t s1, uint32_t s2,
+ uint32_t s3, uint32_t s4, uint32_t s5);
/**
* \brief Set the run number of this simulation
@@ -183,7 +154,7 @@
* after the global seed is set, and before the creation of any
* RandomVariables. For example:
* \code
- * RandomVariable::UseGlobalSeed(ConstantSeed(1,2,3,4,5,6));
+ * RandomVariable::UseGlobalSeed(1,2,3,4,5,6);
* int N = atol(argv[1]); //read in run number from command line
* RandomVariable::SetRunNumber(N);
* UniformVariable x(0,10);