StreamWriter
#include <icy/packetio.h>
class StreamWriterDefined in src/base/include/icy/packetio.h:108
- Inherits
PacketProcessor
This class can be connected to a 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
| Name | Kind | Owner |
|---|---|---|
emitter | variable | Declared here |
StreamWriter | function | Declared here |
~StreamWriter | function | Declared here |
process | function | Declared here |
stream | function | Declared here |
onStreamStateChange | function | Declared here |
stream | function | Declared here |
_ostream | variable | Declared here |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process() |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const | Returns 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. |
function | onStreamStateChange virtual inline | Called 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 | |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
emitter
PacketSignal emitterType: PacketSignal
Defined in src/base/include/icy/packetio.h:188
Public Methods
| Return | Name | Description |
|---|---|---|
StreamWriter inline | ||
~StreamWriter virtual inline | Closes any open std::ofstream and deletes the owned stream. | |
void | process virtual inline override | Serializes the packet via write(), flushes it to the output stream, then forwards the packet to the next processor. |
StreamT & | stream inline | Returns the internal output stream cast to StreamT. |
void | onStreamStateChange virtual inline override | Closes the output file on Closed or 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
| Parameter | Type | Description |
|---|---|---|
stream | std::ostream * | 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) overrideDefined 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.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
packet | IPacket & | Incoming packet to process. |
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.
Returns
Reference to the cast stream.
Exceptions
| Exception | Description |
|---|---|
std::runtime_error | if the cast fails. |
onStreamStateChange
virtual inline override
virtual inline void onStreamStateChange(const PacketStreamState & state) overrideDefined in src/base/include/icy/packetio.h:159
Closes the output file on Closed or Error stream state transitions.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
state | const PacketStreamState & | New stream state. |
stream
inline
inline std::ostream & stream()Defined in src/base/include/icy/packetio.h:181
Returns
Reference to the underlying output stream.
Exceptions
| Exception | Description |
|---|---|
std::runtime_error | if the stream pointer is null. |
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::ostream * | _ostream |
_ostream
std::ostream * _ostream