aboutsummaryrefslogtreecommitdiff
path: root/src/experimental/random.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/experimental/random.h51
1 files changed, 51 insertions, 0 deletions
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 @@
4 * This file is part of the libbu++ library and is released under the 4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7#ifndef BU_RANDOM_H
8#define BU_RANDOM_H
7 9
10#include "bu/singleton.h"
11#include <stdint.h>
12
13namespace Bu
14{
15 class RandomBase;
16 class Random : public Bu::Singleton<Bu::Random>
17 {
18 friend class Bu::Singleton<Bu::Random>;
19 private:
20 Random();
21 virtual ~Random();
22
23 public:
24 template<typename cl>
25 static void setGenerator()
26 {
27 delete getInstance().pGen;
28 getInstance().pGen = new cl();
29 }
30
31 template<typename cl, typename t1>
32 static void setGenerator( t1 p1 )
33 {
34 delete getInstance().pGen;
35 getInstance().pGen = new cl( p1 );
36 }
37
38 template<typename cl, typename t1, typename t2>
39 static void setGenerator( t1 p1, t2 p2 )
40 {
41 delete getInstance().pGen;
42 getInstance().pGen = new cl( p1, p2 );
43 }
44
45 RandomBase &getGenerator() { return *pGen; }
46
47 static int32_t rand();
48 static void seed( int32_t iSeed );
49
50 private:
51 void checkInit();
52
53 private:
54 Bu::RandomBase *pGen;
55 };
56};
57
58#endif
8 59