/* * Copyright (C) 2007-2012 Xagasoft, All rights reserved. * * 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 void seed( int32_t iSeed ); static int32_t rand(); static int32_t rand( int32_t iMax ); static int32_t rand( int32_t iMin, int32_t iMax ); static double randNorm(); private: void checkInit(); private: Bu::RandomBase *pGen; }; }; #endif