Aikido
aikido::common::RNG Class Referenceabstract

Implementation of the C++11 "random engine" concept that uses virtual function calls to erase the type of the underlying random engine. More...

#include <aikido/common/RNG.hpp>

Inheritance diagram for aikido::common::RNG:
aikido::common::RNGWrapper< T >

Public Types

using result_type = std::uint32_t
 

Public Member Functions

virtual ~RNG ()=default
 
virtual result_type operator() ()=0
 Advances the state of the engine and returns the generated value. More...
 
virtual void discard (unsigned long long _z)=0
 Advances the adaptor's state by a specified amount. More...
 
virtual std::unique_ptr< RNGclone () const =0
 Create a copy of this RNG, including its internal state. More...
 
virtual std::unique_ptr< RNGclone (result_type _seed) const =0
 Create a new RNG of this type with the specified seed. More...
 

Static Public Member Functions

static constexpr result_type min ()
 Gets the smallest possible value in the output range, always zero. More...
 
static constexpr result_type max ()
 Gets the largest possible value in the output range, 2^NUM_BITS - 1. More...
 

Static Public Attributes

static constexpr std::size_t NUM_BITS {32}
 Number of bits the generated numbers should have. More...
 

Detailed Description

Implementation of the C++11 "random engine" concept that uses virtual function calls to erase the type of the underlying random engine.

Member Typedef Documentation

◆ result_type

using aikido::common::RNG::result_type = std::uint32_t

Constructor & Destructor Documentation

◆ ~RNG()

virtual aikido::common::RNG::~RNG ( )
virtualdefault

Member Function Documentation

◆ clone() [1/2]

virtual std::unique_ptr<RNG> aikido::common::RNG::clone ( ) const
pure virtual

Create a copy of this RNG, including its internal state.

Returns
copy of this engine

Implemented in aikido::common::RNGWrapper< T >.

◆ clone() [2/2]

virtual std::unique_ptr<RNG> aikido::common::RNG::clone ( result_type  _seed) const
pure virtual

Create a new RNG of this type with the specified seed.

Parameters
_seednew sed
Returns
new RNG constructed with the specified seed

Implemented in aikido::common::RNGWrapper< T >.

◆ discard()

virtual void aikido::common::RNG::discard ( unsigned long long  _z)
pure virtual

Advances the adaptor's state by a specified amount.

Parameters
_zamount of state to discard

Implemented in aikido::common::RNGWrapper< T >.

◆ max()

constexpr auto aikido::common::RNG::max ( )
staticconstexpr

Gets the largest possible value in the output range, 2^NUM_BITS - 1.

Returns
largest possible value in the output range

◆ min()

constexpr auto aikido::common::RNG::min ( )
staticconstexpr

Gets the smallest possible value in the output range, always zero.

Returns
smallest possible value in the output range

◆ operator()()

virtual result_type aikido::common::RNG::operator() ( )
pure virtual

Advances the state of the engine and returns the generated value.

Returns
random value

Implemented in aikido::common::RNGWrapper< T >.

Member Data Documentation

◆ NUM_BITS

constexpr std::size_t aikido::common::RNG::NUM_BITS {32}
staticconstexpr

Number of bits the generated numbers should have.

Derived types are responsible for providing numbers in this range, if necessary, by wrapping their engine in a std::independent_bits_engine.