The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
randomness::synced_rng Class Reference

#include <random_synced.hpp>

Inheritance diagram for randomness::synced_rng:

Public Member Functions

 synced_rng (std::function< std::string()> seed_generator)
 
virtual ~synced_rng ()
 
virtual bool is_networked () const
 Is this random source networked? If it is it's very important we do actually use this random source to stay in-sync. More...
 
- Public Member Functions inherited from randomness::rng
 rng ()
 
uint32_t next_random ()
 Provides the next random draw. More...
 
virtual ~rng ()
 
unsigned int get_random_calls () const
 Provides the number of random calls to the rng in this context. More...
 
int get_random_int (int min, int max)
 
bool get_random_bool (double probability)
 This helper method returns true with the probability supplied as a parameter. More...
 
double get_random_double ()
 This helper method returns a floating-point number in the range [0,1[. More...
 
template<typename T >
T::difference_type get_random_element (T first, T last)
 This helper method selects a random element from a container of floating-point numbers. More...
 
uint32_t operator() ()
 

Protected Member Functions

virtual uint32_t next_random_impl ()
 

Private Member Functions

void initialize ()
 

Private Attributes

bool has_valid_seed_
 
std::function< std::string()> seed_generator_
 
mt_rng gen_
 

Additional Inherited Members

- Public Types inherited from randomness::rng
using result_type = uint32_t
 
- Static Public Member Functions inherited from randomness::rng
static rngdefault_instance ()
 
- Protected Attributes inherited from randomness::rng
unsigned int random_calls_
 

Detailed Description

Definition at line 28 of file random_synced.hpp.

Constructor & Destructor Documentation

◆ synced_rng()

randomness::synced_rng::synced_rng ( std::function< std::string()>  seed_generator)

Definition at line 29 of file random_synced.cpp.

◆ ~synced_rng()

randomness::synced_rng::~synced_rng ( )
virtual

Definition at line 53 of file random_synced.cpp.

Member Function Documentation

◆ initialize()

void randomness::synced_rng::initialize ( )
private

Definition at line 46 of file random_synced.cpp.

References gen_, has_valid_seed_, seed_generator_, and randomness::mt_rng::seed_random().

Referenced by next_random_impl().

◆ is_networked()

bool randomness::synced_rng::is_networked ( ) const
virtual

Is this random source networked? If it is it's very important we do actually use this random source to stay in-sync.

Reimplemented from randomness::rng.

Definition at line 58 of file random_synced.cpp.

◆ next_random_impl()

uint32_t randomness::synced_rng::next_random_impl ( )
protectedvirtual

Member Data Documentation

◆ gen_

mt_rng randomness::synced_rng::gen_
private

Definition at line 42 of file random_synced.hpp.

Referenced by initialize(), and next_random_impl().

◆ has_valid_seed_

bool randomness::synced_rng::has_valid_seed_
private

Definition at line 40 of file random_synced.hpp.

Referenced by initialize(), and next_random_impl().

◆ seed_generator_

std::function<std::string()> randomness::synced_rng::seed_generator_
private

Definition at line 41 of file random_synced.hpp.

Referenced by initialize().


The documentation for this class was generated from the following files: