8 #ifndef META_OCEAN_BASE_RANDOM_GENERATOR_H
9 #define META_OCEAN_BASE_RANDOM_GENERATOR_H
82 inline unsigned int rand();
90 inline unsigned int lockedRand();
97 inline unsigned int seed()
const;
104 inline unsigned int initialSeed()
const;
117 static constexpr
unsigned int randMax();
130 unsigned int initialSeed_ = (
unsigned int)(-1);
133 unsigned int seed_ = (
unsigned int)(-1);
141 const unsigned int seedLow = generator.
lockedRand() & 0xFFFFu;
142 const unsigned int seedHigh = (generator.
lockedRand() & 0xFFFFu) << 16u;
158 *
this = std::move(randomGenerator);
163 return (
unsigned int)(((
seed_ =
seed_ * 214013L + 2531011L) >> 16) & 0x7fff);
170 return (
unsigned int)(((
seed_ =
seed_ * 214013L + 2531011L) >> 16) & 0x7fff);
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
Lock lock_
Generator lock.
Definition: RandomGenerator.h:136
static unsigned int threadAndTimeBasedSeed()
Returns a seed value based on the current time, the thread id, and a random value from RandomI.
unsigned int lockedRand()
Returns the next random number.
Definition: RandomGenerator.h:166
unsigned int rand()
Returns the next random number.
Definition: RandomGenerator.h:161
static constexpr unsigned int randMax()
Returns the maximal random value of this generator.
Definition: RandomGenerator.h:183
unsigned int initialSeed_
The seed value which was used to initialize this random generator.
Definition: RandomGenerator.h:130
unsigned int seed() const
Returns the current seed value of this object.
Definition: RandomGenerator.h:173
RandomGenerator & operator=(RandomGenerator &&randomGenerator)
Move operator.
unsigned int initialSeed() const
Returns the initial seed value which was used to initialize this random generator.
Definition: RandomGenerator.h:178
unsigned int seed_
Internal seed parameter used for random number generation, changes whenever a new random number is ge...
Definition: RandomGenerator.h:133
RandomGenerator(RandomGenerator *optionalGenerator)
Creates a new random generator and optional initializes the internal parameter by a random value prov...
RandomGenerator()
Creates a new random generator and initializes the internal parameter with the random value of the st...
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15