From 2295579eb790d6eff6e54e84c01da6de10809a71 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 May 2012 16:57:15 +0000 Subject: Better win_o ignores. The random number system is pretty much together. We need a few extra helper functions to cover some other good things, like normalized floating point numbers, etc. --- src/experimental/random.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/experimental/random.h') diff --git a/src/experimental/random.h b/src/experimental/random.h index c792772..ba26f21 100644 --- a/src/experimental/random.h +++ b/src/experimental/random.h @@ -4,5 +4,56 @@ * This file is part of the libbu++ library and is released under the * terms of the license contained in the file LICENSE. */ +#ifndef BU_RANDOM_H +#define BU_RANDOM_H +#include "bu/singleton.h" +#include + +namespace Bu +{ + class RandomBase; + class Random : public Bu::Singleton + { + friend class Bu::Singleton; + private: + Random(); + virtual ~Random(); + + public: + template + static void setGenerator() + { + delete getInstance().pGen; + getInstance().pGen = new cl(); + } + + template + static void setGenerator( t1 p1 ) + { + delete getInstance().pGen; + getInstance().pGen = new cl( p1 ); + } + + template + static void setGenerator( t1 p1, t2 p2 ) + { + delete getInstance().pGen; + getInstance().pGen = new cl( p1, p2 ); + } + + RandomBase &getGenerator() { return *pGen; } + + static int32_t rand(); + static void seed( int32_t iSeed ); + + private: + void checkInit(); + + private: + Bu::RandomBase *pGen; + }; +}; + +#endif -- cgit v1.2.3