18 #ifndef LUNCHBOX_RNG_H 
   19 #define LUNCHBOX_RNG_H 
   21 #include <lunchbox/debug.h>  
   22 #include <lunchbox/init.h>   
   24 #include <boost/noncopyable.hpp> 
   29 namespace detail { 
class RNG; }
 
   40 class RNG : 
public boost::noncopyable
 
   50     LUNCHBOX_API 
void reseed();
 
   60     template< 
typename T > T 
get()
 
   63             if( !_get( &value, 
sizeof( T )))
 
   69     detail::RNG* 
const _impl;
 
   71     static LUNCHBOX_API 
bool _init();
 
   73     friend LUNCHBOX_API 
bool init( 
const int argc, 
char** argv );
 
   74     LUNCHBOX_API 
bool _get( 
void* data, 
size_t size );
 
   79     const float max_limits =
 
   80         static_cast< float >( std::numeric_limits< uint32_t >::max( ));
 
   81     return ((
float)get< uint32_t >() / max_limits);
 
   86     const double max_limits =
 
   87         static_cast< double >( std::numeric_limits< uint64_t >::max( ));
 
   88     return ((
double)get< uint64_t >() / max_limits);
 
   93     return ( get< uint32_t >() & 1 );
 
   96 #endif  // LUNCHBOX_RNG_H 
Basic type definitions not provided by the operating system. 
 
A random number generator. 
 
LUNCHBOX_API RNG()
Construct a new random number generator. 
 
friend LUNCHBOX_API bool init(const int argc, char **argv)
Initialize the Lunchbox base classes. 
 
LUNCHBOX_API void reseed()
Re-initialize the seed value for pseudo RNG's. 
 
LUNCHBOX_API ~RNG()
Destruct the random number generator. 
 
T get()
Generate a random number.