Home
Base module

StreamWriter

Packet stream writer class.

StreamWriter

#include <icy/packetio.h>
class StreamWriter

Defined in src/base/include/icy/packetio.h:108

Inherits: PacketProcessor

Packet stream writer class.

This class can be connected to a [PacketStream](icy-PacketStream.html#packetstream) to write output to any class that derives from std::ostream. It's most regularly used for writing output files.

List of all members

NameKindOwner
emittervariableDeclared here
StreamWriterfunctionDeclared here
~StreamWriterfunctionDeclared here
processfunctionDeclared here
streamfunctionDeclared here
onStreamStateChangefunctionDeclared here
streamfunctionDeclared here
_ostreamvariableDeclared here
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Public Attributes

ReturnNameDescription
PacketSignalemitter

emitter

PacketSignal emitter

Defined in src/base/include/icy/packetio.h:188

Public Methods

ReturnNameDescription
StreamWriter inline
~StreamWriter virtual inlineCloses any open std::ofstream and deletes the owned stream.
voidprocess virtual inline overrideSerializes the packet via write(), flushes it to the output stream, then forwards the packet to the next processor.
StreamT &stream inlineReturns the internal output stream cast to StreamT.
voidonStreamStateChange virtual inline overrideCloses the output file on Closed or [Error](icy-Error.html#error) stream state transitions.
std::ostream &stream inline

StreamWriter

inline

inline StreamWriter(std::ostream * stream)

Defined in src/base/include/icy/packetio.h:112

Parameters

  • stream Output stream to write to; takes ownership.

~StreamWriter

virtual inline

virtual inline ~StreamWriter()

Defined in src/base/include/icy/packetio.h:119

Closes any open std::ofstream and deletes the owned stream.


process

virtual inline override

virtual inline void process(IPacket & packet) override

Defined in src/base/include/icy/packetio.h:132

Serializes the packet via write(), flushes it to the output stream, then forwards the packet to the next processor.

Parameters

  • packet Incoming packet to process.
Reimplements

stream

inline

template<class StreamT> inline StreamT & stream()

Defined in src/base/include/icy/packetio.h:148

Returns the internal output stream cast to StreamT.

Parameters

  • StreamT Target stream type derived from std::ostream.

Returns

Reference to the cast stream.

Exceptions

  • std::runtime_error if the cast fails.

onStreamStateChange

virtual inline override

virtual inline void onStreamStateChange(const PacketStreamState & state) override

Defined in src/base/include/icy/packetio.h:159

Closes the output file on Closed or [Error](icy-Error.html#error) stream state transitions.

Parameters

  • state New stream state.
Reimplements

stream

inline

inline std::ostream & stream()

Defined in src/base/include/icy/packetio.h:181

Returns

Reference to the underlying output stream.

Exceptions

  • std::runtime_error if the stream pointer is null.

Protected Attributes

ReturnNameDescription
std::ostream *_ostream

_ostream

std::ostream * _ostream

Defined in src/base/include/icy/packetio.h:191