38 std::lock_guard<std::mutex>
lg(streamMutex);
39 if (stream !=
nullptr) {
64 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
65 if (mPriv->stream ==
nullptr) {
66 return mPriv->nullStream;
68 return mPriv->stream->getInputStream();
74 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
75 if (mPriv->stream ==
nullptr) {
76 return mPriv->nullStream;
78 return mPriv->stream->getOutputStream();
84 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
85 return (mPriv->stream ==
nullptr) ? mPriv->nullStream.getLocalAddress()
86 : (mPriv->stream->getLocalAddress());
92 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
93 return (mPriv->stream ==
nullptr) ? mPriv->nullStream.getRemoteAddress()
94 : (mPriv->stream->getRemoteAddress());
105 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
106 mPriv->stream = stream;
111 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
113 mPriv->stream =
nullptr;
119 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
120 return mPriv->stream;
125 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
126 return mPriv->stream ==
nullptr;
131 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
132 if (mPriv->stream !=
nullptr) {
133 return mPriv->stream->isOk();
140 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
141 if (mPriv->stream !=
nullptr) {
142 mPriv->stream->reset();
148 if (mPriv->stream !=
nullptr) {
149 mPriv->stream->beginPacket();
155 if (mPriv->stream !=
nullptr) {
156 mPriv->stream->endPacket();
163 std::lock_guard<std::mutex>
lg(mPriv->streamMutex);
164 if (mPriv->stream !=
nullptr) {
165 mPriv->stream->getInputStream().interrupt();
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
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 interruptInputStream()
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
ShiftStream()
Constructor.
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.