22 #ifndef __M2ETIS_UTILS_RANDOM_H__
23 #define __M2ETIS_UTILS_RANDOM_H__
30 #include "boost/date_time.hpp"
31 #include "boost/thread/mutex.hpp"
44 static unsigned int rand() {
45 boost::mutex::scoped_lock l(lock);
46 return random.getRand();
52 static unsigned int rand(
unsigned int max) {
62 static unsigned int rand(
unsigned int min,
unsigned int max) {
66 return (
rand() % (max - min)) + min;
78 std::minstd_rand * _linear;
83 static boost::mutex lock;
88 Random() : _linear(new
std::minstd_rand(17)) {
101 unsigned int getRand() {
return (*_linear)(); }
static unsigned int rand(unsigned int min, unsigned int max)
returns a random number in the range between min and max
static unsigned int rand()
returns a random number in range of unsigned int
static unsigned int rand(unsigned int max)
returns a random number in the range between 0 and max
#define M2ETIS_THROW_API(module, message)
throws on wrong API usage