Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
StreamReceiverInterface.hxx
Go to the documentation of this file.
1
35#ifndef _OPENLCB_STREAMRECEIVERINTERFACE_HXX_
36#define _OPENLCB_STREAMRECEIVERINTERFACE_HXX_
37
39#include "openlcb/Defs.hxx"
41
42template <class T> class FlowInterface;
43template <class T> class Buffer;
44struct ByteChunk;
47
48namespace openlcb
49{
50
51class Node;
52
54{
55 enum
56 {
60 ERROR_CANCELED = Defs::ERROR_OUT_OF_ORDER | 1,
61 };
62
72
91 void reset(ByteSink *target, Node *dst, NodeHandle src,
92 uint8_t src_stream_id = StreamDefs::INVALID_STREAM_ID,
93 uint8_t dst_stream_id = StreamDefs::INVALID_STREAM_ID,
94 uint16_t max_window = 0)
95 {
96 reset_base();
97 HASSERT(target);
98 target_ = target;
99 src_ = src;
100 dst_ = dst;
101 srcStreamId_ = src_stream_id;
102 localStreamId_ = dst_stream_id;
103 streamWindowSize_ = max_window;
105 }
106
108 ByteSink *target_ {nullptr};
112 Node *dst_ {nullptr};
120 uint16_t streamWindowSize_ {0};
121};
122
123class StreamReceiverInterface : public CallableFlow<StreamReceiveRequest>
124{
125public:
128 { }
129
133 virtual void cancel_request() = 0;
134};
135
136} // namespace openlcb
137
138#endif // _OPENLCB_STREAMRECEIVERINTERFACE_HXX_
Base class for all QMember types that hold data in an expandable format.
Definition Buffer.hxx:195
Abstract class for message recipients.
Node information.
Definition Devtab.hxx:549
Collection of related state machines that pend on incoming messages.
Base class for NMRAnet nodes conforming to the asynchronous interface.
Definition Node.hxx:52
virtual void cancel_request()=0
Cancels the currently pending stream receive request.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
Definition macros.h:138
Holds a reference to a raw buffer, with the start and size information.
All callable flow request objects have to derive from this struct.
void reset_base()
Call this from all instances of reset(...).
int resultCode
If high bits are zero, this is a 16-bit OpenLCB result code.
Container of both a NodeID and NodeAlias.
static constexpr uint8_t INVALID_STREAM_ID
This value is invalid as a source or destination stream ID.
ByteSink * target_
Where to send the incoming stream data.
void reset()
Gets a local stream ID.
uint8_t srcStreamId_
Source (remote) stream ID. May be INVALID_STREAM_ID.
uint16_t streamWindowSize_
if non-zero, limits the maximum window size by the local side.
uint8_t localStreamId_
Local (target) stream ID. Must be valid.
Node * dst_
Local node for receiving the stream.
NodeHandle src_
Remote node that will send us the stream.
@ ERROR_CANCELED
The operation was canceled by the caller using cancel_request()
@ OPERATION_PENDING
This bit in the resultCode is cleared when done is called.
void reset(ByteSink *target, Node *dst, NodeHandle src, uint8_t src_stream_id=StreamDefs::INVALID_STREAM_ID, uint8_t dst_stream_id=StreamDefs::INVALID_STREAM_ID, uint16_t max_window=0)
Starts the stream receiver and prepares for an announced stream.