22#include "comms/details/detect.h"
23#include "comms/details/process.h"
51template <
typename TBufIter,
typename TFrame,
typename TMsg,
typename... TExtraValues>
57 TExtraValues... extraValues)
59 std::size_t consumed = 0U;
61 comms::util::makeScopeGuard(
62 [&bufIter, &consumed]()
64 std::advance(bufIter, consumed);
66 static_cast<void>(onExit);
68 while (consumed < len) {
73 auto es = frame.read(msg, iter, len - consumed, extraValues...);
84 consumed +=
static_cast<decltype(consumed)
>(std::distance(begIter, iter));
118template <
typename TBufIter,
typename TFrame,
typename TMsg,
typename THandler,
typename... TExtraValues>
125 TExtraValues... extraValues)
127 using LocalMsgIdType = details::ProcessMsgIdType<
typename std::decay<
decltype(msg)>::type>;
128 LocalMsgIdType
id = LocalMsgIdType();
129 std::size_t idx = 0U;
135 std::forward<TFrame>(frame),
145 static_cast<void>(handler);
146 using FrameType =
typename std::decay<
decltype(frame)>::type;
147 using AllMessagesType =
typename FrameType::AllMessages;
148 auto& msgObj = details::processMsgCastToMsgObj(msg);
149 comms::dispatchMsg<AllMessagesType>(
id, idx, msgObj, handler);
183template <
typename TDispatcher,
typename TBufIter,
typename TFrame,
typename TMsg,
typename THandler,
typename... TExtraValues>
190 TExtraValues... extraValues)
192 using LocalMsgIdType = details::ProcessMsgIdType<
typename std::decay<
decltype(msg)>::type>;
193 static_assert(!std::is_void<LocalMsgIdType>(),
"Invalid type of msg param");
195 LocalMsgIdType
id = LocalMsgIdType();
196 std::size_t idx = 0U;
202 std::forward<TFrame>(frame),
212 using FrameType =
typename std::decay<
decltype(frame)>::type;
213 using AllMessagesType =
typename FrameType::AllMessages;
215 comms::isMsgDispatcher<TDispatcher>(),
216 "TDispatcher is expected to be a variant of comms::MsgDispatcher");
218 auto& msgObj = details::processMsgCastToMsgObj(msg);
219 TDispatcher::template dispatch<AllMessagesType>(
id, idx, msgObj, handler);
245template <
typename TBufIter,
typename TFrame,
typename THandler,
typename... TExtraValues>
252 std::size_t consumed = 0U;
253 using FrameType =
typename std::decay<
decltype(frame)>::type;
254 using MsgPtr =
typename FrameType::MsgPtr;
255 while (consumed < len) {
256 auto begIter = bufIter + consumed;
261 consumed +=
static_cast<decltype(consumed)
>(std::distance(begIter, iter));
294template <
typename TDispatcher,
typename TBufIter,
typename TFrame,
typename THandler,
typename... TExtraValues>
301 std::size_t consumed = 0U;
302 using FrameType =
typename std::decay<
decltype(frame)>::type;
303 using MsgPtr =
typename FrameType::MsgPtr;
304 while (consumed < len) {
305 auto begIter = bufIter + consumed;
309 auto es = processSingleWithDispatchViaDispatcher<TDispatcher>(iter, len - consumed, std::forward<TFrame>(frame), msg, handler);
310 consumed +=
static_cast<decltype(consumed)
>(std::distance(begIter, iter));
This file contains classes required for generic custom assertion functionality.
#define COMMS_ASSERT(expr)
Generic assert macro.
Definition Assert.h:170
This file contain definition of error statuses used by comms module.
Contains definition of Message object interface and various base classes for custom messages.
Contains definition of MsgDispatcher class which facilitates dispatching of message object to appropr...
Contains definition of comms::protocol::ProtocolLayerBase.
Contains definition of the "Scope Guard" idiom, see comms::util::ScopeGuard.
Contains extra logic to help with dispatching message types and objects.
Provides auxiliary functions for retrieving best type of iterator for read/write operations.
details::MsgIdRetriever< TId > msgId(TId &val)
Add "message ID" output parameter to protocol stack's (frame's) "read" operation.
Definition ProtocolLayerBase.h:1588
details::MsgIndexRetriever msgIndex(std::size_t &val)
Add "message index" output parameter to protocol stack's (frame's) "read" operation.
Definition ProtocolLayerBase.h:1626
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
@ Success
Used to indicate successful outcome of the operation.
std::size_t processAllWithDispatch(TBufIter bufIter, std::size_t len, TFrame &&frame, THandler &handler)
Process all available input and dispatch all created message objects to appropriate handling function...
Definition process.h:246
auto readIteratorFor(TIter &&iter) -> decltype(details::ReadIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message read.
Definition iterator.h:24
comms::ErrorStatus processSingle(TBufIter &bufIter, std::size_t len, TFrame &&frame, TMsg &msg, TExtraValues... extraValues)
Process input until first message is recognized and its object is created or missing data is reported...
Definition process.h:52
comms::ErrorStatus processSingleWithDispatch(TBufIter &bufIter, std::size_t len, TFrame &&frame, TMsg &msg, THandler &handler, TExtraValues... extraValues)
Process input until first message is recognized, its object is created and dispatched to appropriate ...
Definition process.h:119
comms::ErrorStatus processSingleWithDispatchViaDispatcher(TBufIter &bufIter, std::size_t len, TFrame &&frame, TMsg &msg, THandler &handler, TExtraValues... extraValues)
Process input until first message is recognized, its object is created and dispatched to appropriate ...
Definition process.h:184
std::size_t processAllWithDispatchViaDispatcher(TBufIter bufIter, std::size_t len, TFrame &&frame, THandler &handler)
Process all available input and dispatch all created message objects to appropriate handling function...
Definition process.h:295