Fix use of singleton pattern.
[tagua/yd.git] / src / random.cpp
blob35d646832737072e84304b4007f6e63ca6b71c5b
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "random.h"
13 Random::Random() { }
15 Random::IntegerGenerator Random::rand(int min, int max) {
16 return IntegerGenerator(&m_generator, IntegerDistribution(min, max));
19 Random::RealGenerator Random::rand(float min, float max) {
20 return RealGenerator(&m_generator, RealDistribution(min, max));
23 Random::RealGenerator Random::rand(double min, double max) {
24 return rand(static_cast<float>(min),
25 static_cast<float>(max));
28 Random& Random::instance() {
29 static Random instance;
30 return instance;