25 #ifndef __I6ENGINE_UTILS_RANDOM_H__
26 #define __I6ENGINE_UTILS_RANDOM_H__
34 #include "boost/date_time.hpp"
63 uint32_t
rand(uint32_t max)
const {
67 return getRand() % max;
73 uint32_t
rand(uint32_t min, uint32_t max)
const {
75 ISIXE_THROW_API(
"i6eRandom",
"max value has to be greater than min value")
77 return (getRand() % (max - min)) + min;
84 std::lock_guard<std::mutex> l(_lock);
92 std::minstd_rand * _linear;
97 mutable std::mutex _lock;
102 uint32_t getRand()
const {
103 std::lock_guard<std::mutex> l(_lock);
110 Random() : _linear(new std::minstd_rand(static_cast<unsigned int>(
boost::posix_time::time_period(
boost::posix_time::time_from_string(
"2010-03-19 14:23:10"),
boost::posix_time::microsec_clock::universal_time()).length().total_microseconds()))), _lock() {
Derive from this templated class to make a class a singleton. Refer to the Singleton Design Pattern i...
#define ISIXE_THROW_API(module, message)
uint32_t rand(uint32_t max) const
returns a random number in the range between 0 and max ([0;max[)
uint32_t rand() const
returns a random number in range of unsigned int
uint32_t rand(uint32_t min, uint32_t max) const
returns a random number in the range between min and max ([min; max[)
void setSeed(uint32_t seed)
sets a random seed value