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

Helper class for defining streams that forward data to another stream internally. More...

#include <SyncStream.hxx>

Inheritance diagram for WrappedStream:
SyncStream CCMHelper::DecryptorStream MaxLengthStream MinWriteStream

Public Member Functions

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

Protected Attributes

std::unique_ptr< SyncStreamdelegate_
 Where to write the data 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

Helper class for defining streams that forward data to another stream internally.

Definition at line 147 of file SyncStream.hxx.

Constructor & Destructor Documentation

◆ WrappedStream()

WrappedStream::WrappedStream ( SyncStream delegate)
inline

Definition at line 150 of file SyncStream.hxx.

Member Function Documentation

◆ finalize()

int WrappedStream::finalize ( int  status)
inlineoverridevirtual

Called once after all data has been written to close the stream and release resources.

Return 0 on success, <0 on failure.

Parameters
statusis an error code seen by wrapping streams. Default 0 (OK), if negative, streams might want to roll back their changes.

Reimplemented from SyncStream.

Definition at line 168 of file SyncStream.hxx.

◆ set_delegate()

void WrappedStream::set_delegate ( SyncStream delegate)
inline

Overrides the target where to send the incoming data onwards.

Frees (and finalizes) the previous delegate.

Parameters
delegateis the wrapped stream. Takes ownership of the pointer.

Definition at line 158 of file SyncStream.hxx.

Member Data Documentation

◆ delegate_

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

Where to write the data to.

Definition at line 181 of file SyncStream.hxx.


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