class for interfacing random number generators. More...
#include <rng.h>
Public Member Functions | |
| size_t | getRandomNumber (size_t ceil) throw (PWGenException) |
| RNGENGINE | getRNGEngineUsed () const throw () |
| size_t | operator() (size_t ceil) throw (PWGenException) |
| const RNG & | operator= (const RNG &r) throw () |
| RNG (const RNG &r) throw (PWGenException) | |
| RNG (RNGENGINE request=AUTO) throw (PWGenException) | |
| Try a specific RNG Engine or use automatically determination. | |
| virtual | ~RNG () throw () |
Static Public Member Functions | |
| static int | getAvailableRNGs () |
Private Member Functions | |
| size_t | _lrand48 (size_t ceil) throw () |
| size_t | _rand (size_t ceil) throw () |
| size_t | devrandom (size_t ceil) throw (PWGenException) |
| returns a random number using the kernel random number generator | |
| void | init_rng (RNGENGINE request) throw (PWGenException) |
| Initializes the given engine. | |
Static Private Member Functions | |
| static void | check_availability () throw (PWGenException) |
Private Attributes | |
| int | fd |
| file descriptor | |
| bool | rng_initialized |
| is rng initialized | |
| RNGENGINE | rng_used |
| which rng is used | |
Static Private Attributes | |
| static int | rng_available = 0 |
| which rng are available | |
Class for interfacing random number generators. It tries the following random generators:
The random numbers are in the range of size_t, since this is the range of the pool CharacterPool.
Definition at line 71 of file rng.h.
| RNG::RNG | ( | RNGENGINE | request = AUTO |
) | throw (PWGenException) |
Try to initialize the given RNG Engine.
If the AUTO Engine is requested (the default value) the constructor utomatically initializes a suitable random number generator using the order shown below:
It takes the first it finds from the list above.
| request | the requested engine or AUTO for auto determination. |
Definition at line 262 of file rng.cc.
References YAPET::PWGEN::AUTO, YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, YAPET::PWGEN::LRAND48, and YAPET::PWGEN::RAND.
| RNG::RNG | ( | const RNG & | r | ) | throw (PWGenException) |
Definition at line 298 of file rng.cc.
References YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, YAPET::PWGEN::LRAND48, and YAPET::PWGEN::RAND.
| RNG::~RNG | ( | ) | throw () [virtual] |
Definition at line 326 of file rng.cc.
References YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, fd, and rng_used.
| size_t RNG::_lrand48 | ( | size_t | ceil | ) | throw () [private] |
Definition at line 208 of file rng.cc.
References YAPET::PWGEN::LRAND48.
| size_t RNG::_rand | ( | size_t | ceil | ) | throw () [private] |
Definition at line 227 of file rng.cc.
References YAPET::PWGEN::RAND.
| void RNG::check_availability | ( | ) | throw (PWGenException) [static, private] |
Definition at line 72 of file rng.cc.
References rng_available.
Referenced by getAvailableRNGs().

| size_t RNG::devrandom | ( | size_t | ceil | ) | throw (PWGenException) [private] |
return a random number from either /dev/random or /dev/urandom, depending on which is used.
| ceil | the maximum value to return. |
Definition at line 161 of file rng.cc.
References YAPET::PWGEN::DEVRANDOM, and YAPET::PWGEN::DEVURANDOM.
| int RNG::getAvailableRNGs | ( | ) | [static] |
Definition at line 92 of file rng.cc.
References check_availability(), and rng_available.
Referenced by PWGenDialog::PWGenDialog().


| size_t RNG::getRandomNumber | ( | size_t | ceil | ) | throw (PWGenException) |
Definition at line 337 of file rng.cc.
References YAPET::PWGEN::AUTO, YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, YAPET::PWGEN::LRAND48, YAPET::PWGEN::NONE, and YAPET::PWGEN::RAND.
Referenced by operator()().

| RNGENGINE YAPET::PWGEN::RNG::getRNGEngineUsed | ( | ) | const throw () [inline] |
Definition at line 121 of file rng.h.
References rng_used.
Referenced by YAPET::PWGEN::PWGen::getRNGUsed().

| void RNG::init_rng | ( | RNGENGINE | request | ) | throw (PWGenException) [private] |
Initializes the given engine.
Expects check_availabilit() is already called.
| request | the engine requested. |
Definition at line 105 of file rng.cc.
References YAPET::PWGEN::AUTO, YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, YAPET::PWGEN::LRAND48, YAPET::PWGEN::NONE, and YAPET::PWGEN::RAND.
| size_t YAPET::PWGEN::RNG::operator() | ( | size_t | ceil | ) | throw (PWGenException) [inline] |
Definition at line 125 of file rng.h.
References getRandomNumber().

Definition at line 363 of file rng.cc.
References YAPET::PWGEN::DEVRANDOM, YAPET::PWGEN::DEVURANDOM, YAPET::PWGEN::LRAND48, and YAPET::PWGEN::RAND.
int YAPET::PWGEN::RNG::fd [private] |
int RNG::rng_available = 0 [static, private] |
stores which rng are available.
Definition at line 100 of file rng.h.
Referenced by check_availability(), and getAvailableRNGs().
bool YAPET::PWGEN::RNG::rng_initialized [private] |
RNGENGINE YAPET::PWGEN::RNG::rng_used [private] |
stores which rng is used.
Definition at line 93 of file rng.h.
Referenced by getRNGEngineUsed(), and ~RNG().
1.7.1