TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Abstract base class for PRNG's (pseudo-random numbers generators). More...
#include <tsRandomGenerator.h>
Public Member Functions | |
virtual | ~RandomGenerator () |
Virtual destructor. | |
virtual UString | name () const =0 |
Algorithm name (informational only). | |
virtual bool | read (void *addr, size_t size)=0 |
Get random data. | |
virtual bool | readByteBlock (ByteBlock &data, size_t size) |
Get random data in a byte block. | |
template<typename INT_T > requires std::integral<INT_T> | |
bool | readInt (INT_T &value, INT_T min=std::numeric_limits< INT_T >::min(), INT_T max=std::numeric_limits< INT_T >::max()) |
Get a random integer value inside a defined range. | |
virtual bool | ready () const =0 |
Check if the PRNG is ready. | |
virtual bool | seed (const void *addr, size_t size)=0 |
Seed (add entropy) to the PRNG. | |
Abstract base class for PRNG's (pseudo-random numbers generators).
|
pure virtual |
Algorithm name (informational only).
Implemented in ts::BetterSystemRandomGenerator, ts::SystemRandomGenerator, and ts::Xoshiro256ss.
|
pure virtual |
Seed (add entropy) to the PRNG.
[in] | addr | Address of entropy data. |
[in] | size | Size in bytes of entropy data. |
Implemented in ts::SystemRandomGenerator, and ts::Xoshiro256ss.
|
pure virtual |
Check if the PRNG is ready.
If not ready, it must be seeded again.
Implemented in ts::BetterSystemRandomGenerator, ts::SystemRandomGenerator, and ts::Xoshiro256ss.
|
pure virtual |
Get random data.
[out] | addr | Address of returned random data. |
[in] | size | Requested size in bytes of random data. The method always fill the buffer. |
Implemented in ts::BetterSystemRandomGenerator, ts::SystemRandomGenerator, and ts::Xoshiro256ss.
|
virtual |
Get random data in a byte block.
The default implementation uses read().
[out] | data | Returned random data. |
[in] | size | Requested size in bytes of random data. |
bool ts::RandomGenerator::readInt | ( | INT_T & | value, |
INT_T | min = std::numeric_limits<INT_T>::min() , |
||
INT_T | max = std::numeric_limits<INT_T>::max() |
||
) |
Get a random integer value inside a defined range.
INT_T | An integer type for the result. |
[out] | value | The return integer value. |
[in] | min | Minimum value to return. |
[in] | max | Maximum value to return. |