38 if (stream !=
nullptr) {
46 ShiftStream::ShiftStream() :
63 if (mPriv->stream ==
nullptr) {
64 return mPriv->nullStream;
66 return mPriv->stream->getInputStream();
72 if (mPriv->stream ==
nullptr) {
73 return mPriv->nullStream;
75 return mPriv->stream->getOutputStream();
81 return (mPriv->stream ==
nullptr) ? mPriv->nullStream.getLocalAddress()
82 : (mPriv->stream->getLocalAddress());
88 return (mPriv->stream ==
nullptr) ? mPriv->nullStream.getRemoteAddress()
89 : (mPriv->stream->getRemoteAddress());
100 mPriv->stream = stream;
106 mPriv->stream =
nullptr;
112 return mPriv->stream;
117 return mPriv->stream ==
nullptr;
122 if (mPriv->stream !=
nullptr) {
123 return mPriv->stream->isOk();
130 if (mPriv->stream !=
nullptr) {
131 mPriv->stream->reset();
137 if (mPriv->stream !=
nullptr) {
138 mPriv->stream->beginPacket();
144 if (mPriv->stream !=
nullptr) {
145 mPriv->stream->endPacket();
A "null" stream, always invalid.
Simple specification of the minimum functions needed from output streams.
A container for a stream, allowing the stream implementation to be replaced when needed.
void endPacket() override
Mark the end of a logical packet (see beginPacket).
virtual void takeStream(TwoWayStream *stream)
Wrap the supplied stream.
virtual ~ShiftStream()
Destructor.
bool isOk() const override
Check if the stream is ok or in an error state.
virtual TwoWayStream * giveStream()
Removes the wrapped stream and returns it.
InputStream & getInputStream() override
Get an InputStream to read from.
virtual void check() const
Perform maintenance actions, if needed.
virtual TwoWayStream * getStream() const
void reset() override
Reset the stream.
void beginPacket() override
Mark the beginning of a logical packet.
const Contact & getLocalAddress() const override
Get the address of the local side of the stream.
virtual bool isEmpty() const
const Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
void close() override
Terminate the stream.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
A stream which can be asked to perform bidirectional communication.