Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
mygsl::seed_manager Class Reference

#include <bayeux/mygsl/seed_manager.h>

Public Types

enum  init_seed_from_type {
  INIT_SEED_FROM_UNDEFINED = 0, INIT_SEED_FROM_CURRENT_TIME = datatools::bit_mask::bit00, INIT_SEED_FROM_CURRENT_PID = datatools::bit_mask::bit01, INIT_SEED_FROM_URANDOM = datatools::bit_mask::bit02,
  INIT_SEED_FROM_RANDOM_DEVICE = datatools::bit_mask::bit03, INIT_SEED_FROM_USER = datatools::bit_mask::bit04, INIT_SEED_FROM_CURRENT_TIME_AND_PID = INIT_SEED_FROM_CURRENT_TIME | INIT_SEED_FROM_CURRENT_PID, INIT_SEED_FROM_DEFAULT = INIT_SEED_FROM_RANDOM_DEVICE
}
 The entropy strategy used to choose a seed for randomization of seeds. More...
 

Public Member Functions

 seed_manager ()
 Default constructor: More...
 
virtual ~seed_manager ()
 Destructor: More...
 
void get_labels (std::vector< std::string > &labels_) const
 Build an array of all the PRNGs' labels stored in the manager. More...
 
bool has_seed (const std::string &label_) const
 Check is a PRNG with a given label has an associated seed. More...
 
void add_seed (const std::string &label_, int32_t seed_)
 Install the seed value associated to a PRNG with a given label. More...
 
int32_t get_seed (const std::string &label_) const
 Get the seed value associated to a PRNG with a given label. More...
 
void update_seed (const std::string &label_, int32_t seed_)
 Change the seed value associated to a PRNG with a given label. More...
 
void invalidate_seed (const std::string &label_)
 Invalidate the seed value associated to a PRNG with a given label. More...
 
void clear ()
 Clear the list of stored seeds. More...
 
void invalidate ()
 Make all seeds associated to all PRNGs invalid. More...
 
void all_time_seeds ()
 Make all seeds associated to all PRNGs set by the current time. More...
 
void all_auto_seeds ()
 Make all seeds associated to all PRNGs set automatically. More...
 
void transform_time_seeds (bool allow_duplication_=false)
 Compute the effective seeds' values from the current time. More...
 
void ensure_different_seeds ()
 Compute the effective seeds' values to be all different from each others. More...
 
bool all_different_seeds () const
 Check if all valid seeds are differents : More...
 
bool has_auto_seeds () const
 Check if some valid seeds are 'auto' : More...
 
bool has_time_seeds () const
 Check if some valid seeds are 'time' : More...
 
bool has_invalid_seeds () const
 Check if some seeds are 'invalid' : More...
 
size_t size () const
 Returns the number of PRNG's seed values storedin the manager. More...
 
bool empty () const
 Check if the manager is empty. More...
 
void set_init_seed_flags (uint32_t)
 Set the entropy strategy flags. More...
 
uint32_t get_init_seed_flags () const
 Return the entropy strategy flags. More...
 
void dump (std::ostream &) const
 Basic print. More...
 

Static Public Member Functions

static bool seed_is_valid (int32_t seed)
 Return true if supplied integer can be treated as a seed. More...
 

Protected Member Functions

void _ensure_different_seeds (mygsl::rng *random_=0)
 
int32_t _set_seed_for_seeds ()
 
void _set_seed (const std::string &label_, int32_t seed_)
 

Friends

std::ostream & operator<< (std::ostream &, const seed_manager &)
 Store the seeds informations in a stream. More...
 
std::istream & operator>> (std::istream &, seed_manager &)
 Load the seeds informations froma stream. More...
 

Detailed Description

A seed manager instance is responsible to save a collection of seeds used to initialize a set of pseudo-random number generators (PRNG). As the PRNGs are all labelled with a unique name. The seed manager uses an internal dictionary to store the seeds. It is possible to force a seed value for a given PRNG as well as to use a seed determined by some specific PRNG initialized with the current time. I/O operations on streams enable to store and load the content of the seed manager.

Member Enumeration Documentation

◆ init_seed_from_type

The entropy strategy used to choose a seed for randomization of seeds.

Enumerator
INIT_SEED_FROM_UNDEFINED 
INIT_SEED_FROM_CURRENT_TIME 
INIT_SEED_FROM_CURRENT_PID 
INIT_SEED_FROM_URANDOM 
INIT_SEED_FROM_RANDOM_DEVICE 
INIT_SEED_FROM_USER 
INIT_SEED_FROM_CURRENT_TIME_AND_PID 
INIT_SEED_FROM_DEFAULT 

Constructor & Destructor Documentation

◆ seed_manager()

mygsl::seed_manager::seed_manager ( )

Default constructor:

◆ ~seed_manager()

virtual mygsl::seed_manager::~seed_manager ( )
virtual

Destructor:

Member Function Documentation

◆ _ensure_different_seeds()

void mygsl::seed_manager::_ensure_different_seeds ( mygsl::rng random_ = 0)
protected

◆ _set_seed()

void mygsl::seed_manager::_set_seed ( const std::string &  label_,
int32_t  seed_ 
)
protected

◆ _set_seed_for_seeds()

int32_t mygsl::seed_manager::_set_seed_for_seeds ( )
protected

◆ add_seed()

void mygsl::seed_manager::add_seed ( const std::string &  label_,
int32_t  seed_ 
)

Install the seed value associated to a PRNG with a given label.

◆ all_auto_seeds()

void mygsl::seed_manager::all_auto_seeds ( )

Make all seeds associated to all PRNGs set automatically.

◆ all_different_seeds()

bool mygsl::seed_manager::all_different_seeds ( ) const

Check if all valid seeds are differents :

◆ all_time_seeds()

void mygsl::seed_manager::all_time_seeds ( )

Make all seeds associated to all PRNGs set by the current time.

◆ clear()

void mygsl::seed_manager::clear ( )

Clear the list of stored seeds.

◆ dump()

void mygsl::seed_manager::dump ( std::ostream &  ) const

Basic print.

◆ empty()

bool mygsl::seed_manager::empty ( ) const

Check if the manager is empty.

◆ ensure_different_seeds()

void mygsl::seed_manager::ensure_different_seeds ( )

Compute the effective seeds' values to be all different from each others.

◆ get_init_seed_flags()

uint32_t mygsl::seed_manager::get_init_seed_flags ( ) const

Return the entropy strategy flags.

◆ get_labels()

void mygsl::seed_manager::get_labels ( std::vector< std::string > &  labels_) const

Build an array of all the PRNGs' labels stored in the manager.

◆ get_seed()

int32_t mygsl::seed_manager::get_seed ( const std::string &  label_) const

Get the seed value associated to a PRNG with a given label.

◆ has_auto_seeds()

bool mygsl::seed_manager::has_auto_seeds ( ) const

Check if some valid seeds are 'auto' :

◆ has_invalid_seeds()

bool mygsl::seed_manager::has_invalid_seeds ( ) const

Check if some seeds are 'invalid' :

◆ has_seed()

bool mygsl::seed_manager::has_seed ( const std::string &  label_) const

Check is a PRNG with a given label has an associated seed.

◆ has_time_seeds()

bool mygsl::seed_manager::has_time_seeds ( ) const

Check if some valid seeds are 'time' :

◆ invalidate()

void mygsl::seed_manager::invalidate ( )

Make all seeds associated to all PRNGs invalid.

◆ invalidate_seed()

void mygsl::seed_manager::invalidate_seed ( const std::string &  label_)

Invalidate the seed value associated to a PRNG with a given label.

◆ seed_is_valid()

static bool mygsl::seed_manager::seed_is_valid ( int32_t  seed)
static

Return true if supplied integer can be treated as a seed.

◆ set_init_seed_flags()

void mygsl::seed_manager::set_init_seed_flags ( uint32_t  )

Set the entropy strategy flags.

◆ size()

size_t mygsl::seed_manager::size ( ) const

Returns the number of PRNG's seed values storedin the manager.

◆ transform_time_seeds()

void mygsl::seed_manager::transform_time_seeds ( bool  allow_duplication_ = false)

Compute the effective seeds' values from the current time.

◆ update_seed()

void mygsl::seed_manager::update_seed ( const std::string &  label_,
int32_t  seed_ 
)

Change the seed value associated to a PRNG with a given label.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const seed_manager  
)
friend

Store the seeds informations in a stream.

◆ operator>>

std::istream& operator>> ( std::istream &  ,
seed_manager  
)
friend

Load the seeds informations froma stream.


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