Aikido
aikido::common::RNGWrapper< T > Class Template Reference

Concrete implementation of the RNG type erasure class. More...

#include <aikido/common/RNG.hpp>

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

Public Types

using engine_type = std::independent_bits_engine< T, RNG::NUM_BITS, result_type >
 
using result_type = std::uint32_t
 
- Public Types inherited from aikido::common::RNG
using result_type = std::uint32_t
 

Public Member Functions

 RNGWrapper ()=default
 Constructs a random engine with a default seed. More...
 
 RNGWrapper (const T &_rng)
 Constructs a random engine with the state from an existing random engine. More...
 
 RNGWrapper (result_type _seed)
 Constructs a random engine with the specified seed. More...
 
virtual ~RNGWrapper ()=default
 
T & rng ()
 Gets the internal random engine. More...
 
const T & rng () const
 Gets the internal random engine. More...
 
result_type operator() () override
 Advances the state of the engine and returns the generated value. More...
 
void discard (unsigned long long _z) override
 Advances the adaptor's state by a specified amount. More...
 
std::unique_ptr< RNGclone () const override
 Create a copy of this RNG, including its internal state. More...
 
std::unique_ptr< RNGclone (result_type _seed) const override
 Create a new RNG of this type with the specified seed. More...
 
- Public Member Functions inherited from aikido::common::RNG
virtual ~RNG ()=default
 

Private Attributes

engine_type mRng
 

Additional Inherited Members

- Static Public Member Functions inherited from aikido::common::RNG
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 inherited from aikido::common::RNG
static constexpr std::size_t NUM_BITS {32}
 Number of bits the generated numbers should have. More...
 

Detailed Description

template<class T>
class aikido::common::RNGWrapper< T >

Concrete implementation of the RNG type erasure class.

Template Parameters
typeof random engine to wrap

Member Typedef Documentation

◆ engine_type

template<class T >
using aikido::common::RNGWrapper< T >::engine_type = std::independent_bits_engine<T, RNG::NUM_BITS, result_type>

◆ result_type

template<class T >
using aikido::common::RNG::result_type = std::uint32_t

Constructor & Destructor Documentation

◆ RNGWrapper() [1/3]

template<class T >
aikido::common::RNGWrapper< T >::RNGWrapper ( )
default

Constructs a random engine with a default seed.

◆ RNGWrapper() [2/3]

template<class T >
aikido::common::RNGWrapper< T >::RNGWrapper ( const T &  _rng)
explicit

Constructs a random engine with the state from an existing random engine.

Parameters
_rnginstance to use for initialization

◆ RNGWrapper() [3/3]

template<class T >
aikido::common::RNGWrapper< T >::RNGWrapper ( result_type  _seed)
explicit

Constructs a random engine with the specified seed.

Parameters
_seedinitial seed to use for the random engine

◆ ~RNGWrapper()

template<class T >
virtual aikido::common::RNGWrapper< T >::~RNGWrapper ( )
virtualdefault

Member Function Documentation

◆ clone() [1/2]

template<class T >
std::unique_ptr< RNG > aikido::common::RNGWrapper< T >::clone ( ) const
overridevirtual

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

Returns
copy of this engine

Implements aikido::common::RNG.

◆ clone() [2/2]

template<class T >
std::unique_ptr< RNG > aikido::common::RNGWrapper< T >::clone ( result_type  _seed) const
overridevirtual

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

Parameters
_seednew sed
Returns
new RNG constructed with the specified seed

Implements aikido::common::RNG.

◆ discard()

template<class T >
void aikido::common::RNGWrapper< T >::discard ( unsigned long long  _z)
overridevirtual

Advances the adaptor's state by a specified amount.

Parameters
_zamount of state to discard

Implements aikido::common::RNG.

◆ operator()()

template<class T >
auto aikido::common::RNGWrapper< T >::operator() ( )
overridevirtual

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

Returns
random value

Implements aikido::common::RNG.

◆ rng() [1/2]

template<class T >
auto aikido::common::RNGWrapper< T >::rng

Gets the internal random engine.

Returns
internal random engine

◆ rng() [2/2]

template<class T >
const T& aikido::common::RNGWrapper< T >::rng ( ) const

Gets the internal random engine.

Returns
internal random engine

Member Data Documentation

◆ mRng

template<class T >
engine_type aikido::common::RNGWrapper< T >::mRng
private