TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::RandomGenerator Class Referenceabstract

Abstract base class for PRNG's (pseudo-random numbers generators). More...

Inheritance diagram for ts::RandomGenerator:

Public Member Functions

virtual ~RandomGenerator ()
 Virtual destructor.
 
virtual UString name () const =0
 Algorithm name (informational only). More...
 
virtual bool read (void *addr, size_t size)=0
 Get random data. More...
 
virtual bool readByteBlock (ByteBlock &data, size_t size)
 Get random data in a byte block. More...
 
virtual bool ready () const =0
 Check if the PRNG is ready. More...
 
virtual bool seed (const void *addr, size_t size)=0
 Seed (add entropy) to the PRNG. More...
 

Detailed Description

Abstract base class for PRNG's (pseudo-random numbers generators).

Member Function Documentation

◆ name()

virtual UString ts::RandomGenerator::name ( ) const
pure virtual

Algorithm name (informational only).

Returns
The algorithm name.

Implemented in ts::BetterSystemRandomGenerator, and ts::SystemRandomGenerator.

◆ seed()

virtual bool ts::RandomGenerator::seed ( const void *  addr,
size_t  size 
)
pure virtual

Seed (add entropy) to the PRNG.

Parameters
[in]addrAddress of entropy data.
[in]sizeSize in bytes of entropy data.
Returns
True on success, false on error.

Implemented in ts::SystemRandomGenerator.

◆ ready()

virtual bool ts::RandomGenerator::ready ( ) const
pure virtual

Check if the PRNG is ready.

If not ready, it must be seeded again.

Returns
True if the PRNG is ready.

Implemented in ts::BetterSystemRandomGenerator, and ts::SystemRandomGenerator.

◆ read()

virtual bool ts::RandomGenerator::read ( void *  addr,
size_t  size 
)
pure virtual

Get random data.

Parameters
[out]addrAddress of returned random data.
[in]sizeRequested size in bytes of random data. The method always fill the buffer.
Returns
True on success, false on error.

Implemented in ts::BetterSystemRandomGenerator, and ts::SystemRandomGenerator.

◆ readByteBlock()

virtual bool ts::RandomGenerator::readByteBlock ( ByteBlock data,
size_t  size 
)
virtual

Get random data in a byte block.

The default implementation uses read().

Parameters
[out]dataReturned random data.
[in]sizeRequested size in bytes of random data.
Returns
True on success, false on error.

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