aboutsummaryrefslogtreecommitdiff
path: root/common/random.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/random.h')
-rw-r--r--common/random.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/common/random.h b/common/random.h
index 8fc5c4cf7d..90f2ed5cb0 100644
--- a/common/random.h
+++ b/common/random.h
@@ -17,9 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
*/
#ifndef COMMON_RANDOM_H
@@ -29,6 +26,8 @@
namespace Common {
+class String;
+
/**
* Simple random number generator. Although it is definitely not suitable for
* cryptographic purposes, it serves our purposes just fine.
@@ -38,10 +37,17 @@ private:
uint32 _randSeed;
public:
- RandomSource();
+ /**
+ * Construct a new randomness source with the specific name.
+ * The name used name must be globally unique, and is used to
+ * register the randomness source with the active event recorder,
+ * if any.
+ */
+ RandomSource(const String &name);
+
void setSeed(uint32 seed);
- uint32 getSeed() {
+ uint32 getSeed() const {
return _randSeed;
}
@@ -51,12 +57,14 @@ public:
* @return a random number in the interval [0, max]
*/
uint getRandomNumber(uint max);
+
/**
* Generates a random bit, i.e. either 0 or 1.
- * Identical to getRandomNumber(1), but faster, hopefully.
+ * Identical to getRandomNumber(1), but potentially faster.
* @return a random bit, either 0 or 1
*/
uint getRandomBit();
+
/**
* Generates a random unsigned integer in the interval [min, max].
* @param min the lower bound