Base Framework
Public Types | Public Member Functions | List of all members
RandomInputStream Class Reference

#include <base/io/RandomInputStream.h>

Inherits InputStream.

Public Types

enum  { USE_RANDOM_SEED = 0 }
 

Public Member Functions

 RandomInputStream (uint32 seed=USE_RANDOM_SEED)
 
unsigned int available () const noexcept override
 
unsigned int read (uint8 *buffer, const unsigned int _size, bool nonblocking) noexcept override
 
unsigned int skip (unsigned int count) noexcept override
 
void close () noexcept override
 
void wait () const noexcept override
 
bool wait (unsigned int timeout) const noexcept override
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Detailed Description

Random generator input stream.

Constructor & Destructor Documentation

◆ RandomInputStream()

RandomInputStream::RandomInputStream ( uint32  seed = USE_RANDOM_SEED)

Initializes random input stream. If seed is set to USE_RANDOM_SEED (0) a random seed will be used.

Member Function Documentation

◆ available()

unsigned int RandomInputStream::available ( ) const
overridevirtualnoexcept

Returns the number of bytes that can be read or skipped over without blocking under normal circumstances. The number of returned bytes may be less than the true number of bytes available. Attempting to read the number of bytes returned by the function may block the calling thread if some process has acquired a lock on the object (e.g. file locking).

Returns
Available number of bytes in stream.

Implements InputStream.

◆ close()

void RandomInputStream::close ( )
overridevirtualnoexcept

Closes the stream and releases any system resources associated with the stream.

Implements Stream.

◆ read()

unsigned int RandomInputStream::read ( uint8 *  buffer,
const unsigned int  size,
bool  nonblocking 
)
overridevirtualnoexcept

Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes read from the stream.

Implements InputStream.

◆ skip()

unsigned int RandomInputStream::skip ( unsigned int  count)
overridevirtualnoexcept

Skips a specified number of bytes. Blocks if asked to skip more bytes than available.

Parameters
countThe number of bytes to skip.
Returns
The actual number of bytes skipped.

Implements InputStream.

◆ wait() [1/2]

void RandomInputStream::wait ( ) const
overridevirtualnoexcept

Blocking wait for input to become available.

Implements InputStream.

◆ wait() [2/2]

bool RandomInputStream::wait ( unsigned int  timeout) const
overridevirtualnoexcept

Blocking wait for input to become available.

Parameters
timeoutThe timeout periode in microseconds.
Returns
True, if data is available. False, if the timeout periode expired.

Implements InputStream.