Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DelegateStream Class Reference

Stream implementation that allows running a state machine of different streams, typically alternating a header stream and some payload streams. More...

#include <SyncStream.hxx>

Inheritance diagram for DelegateStream:
SyncStream

Public Member Functions

ssize_t write (const void *data, size_t len) override
 Main entry point to the data consumption.
 
- Public Member Functions inherited from SyncStream
virtual int finalize (int status)
 Called once after all data has been written to close the stream and release resources.
 
ssize_t write_all (const void *data, size_t len)
 Repeatedly writes until all data has been consumed or an error occurs.
 

Protected Member Functions

virtual void on_eof ()
 This function will be called when the delegate returns EOF.
 

Protected Attributes

std::unique_ptr< SyncStreamdelegate_
 Stream implementation to delegate the logic to.
 

Additional Inherited Members

- Static Protected Member Functions inherited from SyncStream
static const uint8_t * to_8 (const void *d)
 Converts a void pointer to an equivalent byte pointer.
 
static uint8_t * to_8 (void *d)
 Converts a void pointer to an equivalent byte pointer.
 

Detailed Description

Stream implementation that allows running a state machine of different streams, typically alternating a header stream and some payload streams.

Definition at line 352 of file SyncStream.hxx.

Member Function Documentation

◆ on_eof()

virtual void DelegateStream::on_eof ( )
inlineprotectedvirtual

This function will be called when the delegate returns EOF.

Usually used to process something and then set up a new delegate (or clear delegate which will start returning EOF).

Definition at line 380 of file SyncStream.hxx.

◆ write()

ssize_t DelegateStream::write ( const void *  data,
size_t  len 
)
inlineoverridevirtual

Main entry point to the data consumption.

Parameters
datais the pointer to a block of data to consume.
lenis the number of bytes to consume.
Returns
0 if the stream is completed/EOF (not consuming data anymore); negative value if there is an error; or the number of bytes consumed from the stream.

Implements SyncStream.

Definition at line 355 of file SyncStream.hxx.

Member Data Documentation

◆ delegate_

std::unique_ptr<SyncStream> DelegateStream::delegate_
protected

Stream implementation to delegate the logic to.

Must be instantiated by the implementation of DelegateStream. If null, then the stream will return EOF to the caller.

Definition at line 389 of file SyncStream.hxx.


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