Base module
ThreadedStreamReader
Threaded stream reader class.
ThreadedStreamReader
#include <icy/packetio.h>Inherits:
PacketStreamAdapter,Startable
Threaded stream reader class.
This class can be connected to a [PacketStream](icy-PacketStream.html#packetstream) to read input from any class that derives from std::istream. It's most regularly used for reading input files.
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
emitter
PacketSignal emitterPublic Methods
| Return | Name | Description |
|---|---|---|
ThreadedStreamReader inline | #### Parameters | |
~ThreadedStreamReader inline | Stops the reader thread and deletes the owned stream. | |
void | start virtual inline | Starts the reader thread; emits one line per iteration as a RawPacket. Emits a FlagPacket with PacketFlags::Final on EOF. |
void | stop virtual inline | Cancels the reader thread. |
StreamT & | stream inline | Returns the internal stream cast to StreamT. |
std::istream & | stream inline | #### Returns |
ThreadedStreamReader
inline
inline ThreadedStreamReader(std::istream * is)Parameters
isInput stream to read from; takes ownership.
~ThreadedStreamReader
inline
inline ~ThreadedStreamReader()Stops the reader thread and deletes the owned stream.
start
virtual inline
virtual inline void start()Starts the reader thread; emits one line per iteration as a RawPacket. Emits a FlagPacket with PacketFlags::Final on EOF.
stop
virtual inline
virtual inline void stop()Cancels the reader thread.
stream
inline
template<class StreamT> inline StreamT & stream()Returns the internal stream cast to StreamT.
Parameters
StreamTTarget stream type derived fromstd::istream.
Returns
Reference to the cast stream.
Exceptions
std::runtime_errorif the cast fails.
stream
inline
inline std::istream & stream()Returns
Reference to the underlying input stream.
Protected Attributes
_runner
Thread _runner_istream
std::istream * _istream