COMMS
Template library intended to help with implementation of communication protocols.
|
Main namespace for all classes / functions of COMMS library. More...
Main namespace for all classes / functions of COMMS library.
Namespaces | |
namespace | field |
Namespace that contains definitions of all message fields. | |
namespace | option |
Namespace that contains all the options used to define protocol as well as customize application specific configuration. | |
namespace | protocol |
Namespace that contains definition of layers that can be used to wrap message data with transport data. | |
namespace | traits |
Namespace for various traits tag classes. | |
namespace | units |
Namespace containing units conversion operations. | |
namespace | util |
Namespace for various utility classes and/or functions used by COMMS library. | |
Classes | |
class | Assert |
Base class for any custom assertion behaviour. More... | |
class | EmptyHandler |
Empty message handler, does nothing. More... | |
class | EnableAssert |
Enable new assertion behaviour. More... | |
class | Field |
Base class to all the field classes. More... | |
class | GenericHandler |
Generic common message handler. More... | |
class | GenericMessage |
Generic Message. More... | |
class | Message |
Main interface class for all the messages. More... | |
class | MessageBase |
Base class for all the custom protocol messages. More... | |
class | MsgDispatcher |
An auxiliary class to force a particular way of dispatching message to its handler. More... | |
class | MsgFactory |
Message factory class. More... | |
Typedefs | |
template<typename TFieldBase , typename TExtraOpts = comms::option::app::EmptyOption> | |
using | GenericMessageFields = std::tuple< comms::field::ArrayList< TFieldBase, std::uint8_t, TExtraOpts > > |
Definition of fields for comms::GenericMessage message. | |
template<typename TMsg , typename TDefaultType = std::intmax_t> | |
using | MessageIdType = typename comms::util::LazyDeepConditional< TMsg::InterfaceOptions::HasMsgIdType >::template Type< comms::details::MessageIdTypeRetriever, comms::util::AliasType, TDefaultType, TMsg > |
Get type of message ID used by interface class. | |
Enumerations | |
enum class | ErrorStatus { Success , UpdateRequired , NotEnoughData , ProtocolError , BufferOverflow , InvalidMsgId , InvalidMsgData , MsgAllocFailure , NotSupported , NumOfErrorStatuses } |
Error statuses reported by the Communication module. More... | |
enum class | MsgFactoryCreateFailureReason { None , InvalidId , AllocFailure , NumOfValues } |
Functions | |
template<typename T > | |
details::ValueAssignWrapper< T > | cast_assign (T &value) |
Helper function to assign value with static_cast to appropriate type. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsg (TId &&id, std::size_t index, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsg (TId &&id, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
auto | dispatchMsg (TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior. | |
template<typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsDirect () |
Compile time check whether the message object can use its own polymorphic dispatch() (see Polymorphic Dispatch Message for Handling) when dispatchMsg() is invoked. | |
template<typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsDirect (TMsg &&msg, THandler &&handler) |
Similar to other dispatchMsgIsDirect(), but can help in deducing template arguments. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsPolymorphic () |
Compile time check whether the dispatchMsg() will use "polymorphic" (including "direct") dispatch for provided tuple of messages and handler. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsPolymorphic (TMsg &&msg, THandler &&handler) |
Similar to other dispatchMsgIsPolymorphic(), but can help in deducing template arguments. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsStaticBinSearch () |
Compile time check whether the dispatchMsg() will use "static binary search" dispatch for provided tuple of messages and handler. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
constexpr bool | dispatchMsgIsStaticBinSearch (TMsg &&msg, THandler &&handler) |
Similar to other dispatchMsgIsStaticBinSearch(), but can help in deducing template arguments. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgLinearSwitch (TId &&id, std::size_t index, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgLinearSwitch (TId &&id, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
auto | dispatchMsgLinearSwitch (TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgPolymorphic (TId &&id, std::size_t index, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgPolymorphic (TId &&id, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
auto | dispatchMsgPolymorphic (TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgStaticBinSearch (TId &&id, std::size_t index, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior. | |
template<typename TAllMessages , typename TId , typename TMsg , typename THandler > | |
auto | dispatchMsgStaticBinSearch (TId &&id, TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior. | |
template<typename TAllMessages , typename TMsg , typename THandler > | |
auto | dispatchMsgStaticBinSearch (TMsg &msg, THandler &handler) -> details::MessageInterfaceDispatchRetType< typename std::decay< decltype(handler)>::type > |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgType (TId &&id, std::size_t index, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgType (TId &&id, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior. | |
template<typename TAllMessages , typename TId > | |
std::size_t | dispatchMsgTypeCountStaticBinSearch (TId &&id) |
Count number of message types in the provided tuple that have the requested numeric ID. | |
template<typename TAllMessages > | |
constexpr bool | dispatchMsgTypeIsPolymorphic () |
Compile time check whether the dispatchMsgType() will use "polymorphic" dispatch for provided tuple of messages. | |
template<typename TAllMessages > | |
constexpr bool | dispatchMsgTypeIsStaticBinSearch () |
Compile time check whether the dispatchMsgType() or dispatchMsgType() will use "static binary search" dispatch for provided tuple of messages. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypeLinearSwitch (TId &&id, std::size_t index, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using linear switch behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypeLinearSwitch (TId &&id, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using linear switch behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypePolymorphic (TId &&id, std::size_t index, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using polymorphic behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypePolymorphic (TId &&id, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using polymorphic behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypeStaticBinSearch (TId &&id, std::size_t index, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using static binary search behavior. | |
template<typename TAllMessages , typename TId , typename THandler > | |
bool | dispatchMsgTypeStaticBinSearch (TId &&id, THandler &handler) |
Dispatch message id into appropriate handle() function in the provided handler using static binary search behavior. | |
template<typename TFieldTo , typename TFieldFrom > | |
TFieldTo | field_cast (const TFieldFrom &field) |
Cast between fields. | |
template<typename T > | |
constexpr bool | isMessage () |
Compile time check of of whether the type is a message. | |
template<typename T > | |
constexpr bool | isMessageBase () |
Compile time check of of whether the type is a message extending comms::MessageBase. | |
template<typename TBufIter , typename TFrame , typename THandler , typename... TExtraValues> | |
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. | |
template<typename TDispatcher , typename TBufIter , typename TFrame , typename THandler , typename... TExtraValues> | |
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. | |
template<typename TBufIter , typename TFrame , typename TMsg , typename... TExtraValues> | |
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. | |
template<typename TBufIter , typename TFrame , typename TMsg , typename THandler , typename... TExtraValues> | |
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 handling function, or missing data is reported. | |
template<typename TDispatcher , typename TBufIter , typename TFrame , typename TMsg , typename THandler , typename... TExtraValues> | |
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 handling function, or missing data is reported. | |
template<typename TMessage , typename TIter > | |
auto | readIteratorFor (TIter &&iter) -> decltype(details::ReadIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter))) |
Create and initialise iterator for message read. | |
template<typename TMessage , typename TIter > | |
auto | readIteratorFor (TMessage &&msg, TIter &&iter) -> decltype(details::ReadIteratorHelper<>::template get< typename std::decay< decltype(msg)>::type >(std::forward< TIter >(iter))) |
Create and initialise iterator for message read. | |
template<typename... TOptions> | |
const Message< TOptions... > & | toMessage (const Message< TOptions... > &msg) |
Upcast type of the message object to comms::Message in order to have access to its internal types. | |
template<typename... TOptions> | |
Message< TOptions... > & | toMessage (Message< TOptions... > &msg) |
Upcast type of the message object to comms::Message in order to have access to its internal types. | |
template<typename TMessage , typename... TOptions> | |
const MessageBase< TMessage, TOptions... > & | toMessageBase (const MessageBase< TMessage, TOptions... > &msg) |
Upcast type of the message object to comms::MessageBase in order to have access to its internal types. | |
template<typename TMessage , typename... TOptions> | |
MessageBase< TMessage, TOptions... > & | toMessageBase (MessageBase< TMessage, TOptions... > &msg) |
Upcast type of the message object to comms::MessageBase in order to have access to its internal types. | |
constexpr unsigned | version () |
Version of the COMMS library as single numeric value. | |
constexpr unsigned | versionCreate (unsigned major, unsigned minor, unsigned patch) |
Create version of the library as single unsigned numeric value. | |
constexpr unsigned | versionMajor () |
Major verion of the library. | |
constexpr unsigned | versionMinor () |
Minor verion of the library. | |
constexpr unsigned | versionPatch () |
Patch level of the library. | |
template<typename TMessage , typename TIter > | |
auto | writeIteratorFor (TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter))) |
Create and initialise iterator for message write. | |
template<typename TMessage , typename TIter > | |
auto | writeIteratorFor (TMessage &&msg, TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< typename std::decay< decltype(msg)>::type >(std::forward< TIter >(iter))) |
Create and initialise iterator for message write. | |
using comms::GenericMessageFields = typedef std::tuple< comms::field::ArrayList< TFieldBase, std::uint8_t, TExtraOpts > > |
Definition of fields for comms::GenericMessage message.
Defined as single variable length raw bytes sequence (comms::field::ArrayList).
Base | class for the sequence field definition, expected to be a variant of comms::Field |
Extra | option(s) (bundled as std::tuple if multiple) to be passed to comms::field::ArrayList field definition. |
using comms::MessageIdType = typedef typename comms::util::LazyDeepConditional< TMsg::InterfaceOptions::HasMsgIdType >::template Type< comms::details::MessageIdTypeRetriever, comms::util::AliasType, TDefaultType, TMsg > |
Get type of message ID used by interface class.
In case common interface class defines its message ID type (using comms::option::MsgIdType option) the latter is returned, otherwise the default type (TDefaultType) is reported.
TMsg | Message interface class (extended or typedef-ed comms::Message) |
TDefaultType | Default type to return in case message interface class doesn't define its ID type |
|
strong |
Error statuses reported by the Communication module.
|
strong |
details::ValueAssignWrapper< T > comms::cast_assign | ( | T & | value | ) |
Helper function to assign value with static_cast to appropriate type.
Can be used to assign any value, including value of a field.
auto comms::dispatchMsg | ( | TId && | id, |
std::size_t | index, | ||
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior.
The function performs compile time evaluation of the provided TAllMessages tuple and uses logic described in Default Way to Dispatch to choose the way to dispatch.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsg | ( | TId && | id, |
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior.
The function performs compile time evaluation of the provided TAllMessages tuple and uses logic described in Default Way to Dispatch to choose the way to dispatch.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsg | ( | TMsg & | msg, |
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior.
The function performs compile time evaluation of the provided TAllMessages tuple and uses logic described in Default Way to Dispatch to choose the way to dispatch.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
|
constexpr |
Compile time check whether the message object can use its own polymorphic dispatch() (see Polymorphic Dispatch Message for Handling) when dispatchMsg() is invoked.
TMsg | Type of the message interface. |
THandler | Type of the message handler. |
|
constexpr |
Similar to other dispatchMsgIsDirect(), but can help in deducing template arguments.
msg | Reference to the message object via its interface class. |
handler | Reference to the handler object. |
|
constexpr |
Compile time check whether the dispatchMsg() will use "polymorphic" (including "direct") dispatch for provided tuple of messages and handler.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
TMsg | Type of the common message interface. |
THandler | Type of the handler being used for dispatch. |
|
constexpr |
Similar to other dispatchMsgIsPolymorphic(), but can help in deducing template arguments.
msg | Reference to the message object via its interface class. |
handler | Reference to the handler object. |
|
constexpr |
Compile time check whether the dispatchMsg() will use "static binary search" dispatch for provided tuple of messages and handler.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
TMsg | Type of the common message interface. |
THandler | Type of the handler being used for dispatch. |
|
constexpr |
Similar to other dispatchMsgIsStaticBinSearch(), but can help in deducing template arguments.
msg | Reference to the message object via its interface class. |
handler | Reference to the handler object. |
auto comms::dispatchMsgLinearSwitch | ( | TId && | id, |
std::size_t | index, | ||
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsgLinearSwitch | ( | TId && | id, |
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsgLinearSwitch | ( | TMsg & | msg, |
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using linear switch behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsgPolymorphic | ( | TId && | id, |
std::size_t | index, | ||
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page |
auto comms::dispatchMsgPolymorphic | ( | TId && | id, |
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page |
auto comms::dispatchMsgPolymorphic | ( | TMsg & | msg, |
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using polymorphic behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsgStaticBinSearch | ( | TId && | id, |
std::size_t | index, | ||
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page |
auto comms::dispatchMsgStaticBinSearch | ( | TId && | id, |
TMsg & | msg, | ||
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
auto comms::dispatchMsgStaticBinSearch | ( | TMsg & | msg, |
THandler & | handler | ||
) | -> details::MessageInterfaceDispatchRetType< typename std::decay<decltype(handler)>::type> |
Dispatch message object into appropriate handle() function in the provided handler using static binary search behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | msg | Message object held by reference to its interface class. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Object section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgType | ( | TId && | id, |
std::size_t | index, | ||
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior.
The function performs compile time evaluation of the provided TAllMessages tuple and uses logic described in Default Way to Dispatch to choose the way to dispatch.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page |
bool comms::dispatchMsgType | ( | TId && | id, |
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using either "polymorphic" or "static binary search" behavior.
The function performs compile time evaluation of the provided TAllMessages tuple and uses logic described in Default Way to Dispatch to choose the way to dispatch.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
std::size_t comms::dispatchMsgTypeCountStaticBinSearch | ( | TId && | id | ) |
Count number of message types in the provided tuple that have the requested numeric ID.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
|
constexpr |
Compile time check whether the dispatchMsgType() will use "polymorphic" dispatch for provided tuple of messages.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
|
constexpr |
Compile time check whether the dispatchMsgType() or dispatchMsgType() will use "static binary search" dispatch for provided tuple of messages.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
bool comms::dispatchMsgTypeLinearSwitch | ( | TId && | id, |
std::size_t | index, | ||
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using linear switch behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgTypeLinearSwitch | ( | TId && | id, |
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using linear switch behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgTypePolymorphic | ( | TId && | id, |
std::size_t | index, | ||
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using polymorphic behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgTypePolymorphic | ( | TId && | id, |
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using polymorphic behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgTypeStaticBinSearch | ( | TId && | id, |
std::size_t | index, | ||
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using static binary search behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | index | Index (or offset) of the message type among those having the same ID. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
bool comms::dispatchMsgTypeStaticBinSearch | ( | TId && | id, |
THandler & | handler | ||
) |
Dispatch message id into appropriate handle() function in the provided handler using static binary search behavior.
TAllMessages | std::tuple of supported message classes, sorted in ascending order by their numeric IDs. |
[in] | id | ID of the message known at runtime. |
[in] | handler | Handler object, it's required public interface is explained in Dispatch of the Message Type section of the Advanced Guide to Message Dispatching tutorial page. |
TFieldTo comms::field_cast | ( | const TFieldFrom & | field | ) |
Cast between fields.
Sometimes the protocol may treat some specific field differently based on indication bit in some other field. This function can be used to cast one field to another type.
The function will perform some compile time analysis and will do a simple static_cast between the contained values if they are convertible. Otherwise the write + read operations will be performed, i.e. the source field will be written into a temporary buffer, and the target field will perform a read operation from that buffer.
TFieldTo | Type to cast to. |
TFieldFrom | Type to cast from. |
[in] | field | Original field |
|
constexpr |
Compile time check of of whether the type is a message.
Checks existence of InterfaceOptions inner type.
|
constexpr |
Compile time check of of whether the type is a message extending comms::MessageBase.
Checks existence of ImplOptions inner type.
std::size_t comms::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.
All the created message objects are immediatelly destructed after dispatching.
[in,out] | bufIter | Iterator to input buffer. Passed by value and is NOT updated when buffer is iterated over (unlike comms::processSingle(), comms::processSingleWithDispatch(), comms::processSingleWithDispatchViaDispatcher()). |
[in] | len | Number of remaining bytes in input buffer. |
[in] | frame | Protocol frame / stack (see Transport Framing) that is used to process the raw input. |
[in] | handler | Handler to handle message object when dispatched. The dispatch is performed using comms::dispatchMsg() function. |
std::size_t comms::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.
Similar to comms::processAllWithDispatch(), but allows forcing a particular dispatch policy. All the created message objects are immediatelly destructed after dispatching.
TDispatcher | A variant of comms::MsgDispatcher class. It's going to be used to dispatch message object into appropriate handling function instead of using comms::dispatchMsg() like comms::processSingleWithDispatch() does. |
[in,out] | bufIter | Iterator to input buffer. Passed by value and is NOT updated when buffer is iterated over (unlike comms::processSingle(), comms::processSingleWithDispatch(), comms::processSingleWithDispatchViaDispatcher()). |
[in] | len | Number of remaining bytes in input buffer. |
[in] | frame | Protocol frame / stack (see Transport Framing) that is used to process the raw input. |
[in] | handler | Handler to handle message object when dispatched. The dispatch is performed via provded TDispatcher class (see comms::MsgDispatcher). |
comms::ErrorStatus comms::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.
Can be used to implement Reading Transport Framing and Message Payload.
[in,out] | bufIter | Iterator to input buffer. Passed by reference and is updated when buffer is iterated over. Number of consumed bytes cat be determined by calculating the distance between originally passed value and the one after function returns. |
[in] | len | Number of remaining bytes in input buffer. |
[in] | frame | Protocol frame / stack (see Transport Framing) that is used to process the raw input. |
[in,out] | msg | Smart pointer (see MsgPtr defintion of the Transport Framing) to message object to be allocated, or reference to actual message object (extending comms::MessageBase) when such is known. |
[in,out] | extraValues | Extra values that are passed as variadic parameters to read() member function of the protocol frame / stack. |
comms::ErrorStatus comms::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 handling function, or missing data is reported.
Similar to comms::processSingle(), but adds dispatch stage. Can be used to implement Reading Transport Framing and Message Payload.
[in,out] | bufIter | Iterator to input buffer. Passed by reference and is updated when buffer is iterated over. Number of consumed bytes cat be determined by calculating the distance between originally passed value and the one after function returns. |
[in] | len | Number of remaining bytes in input buffer. |
[in] | frame | Protocol frame / stack (see Transport Framing) that is used to process the raw input. |
[in,out] | msg | Smart pointer (see MsgPtr defintion of the Transport Framing) to message object to be allocated, or reference to actual message object (extending comms::MessageBase) when such is known. |
[in] | handler | Handler to handle message object when dispatched. The dispatch is performed using comms::dispatchMsg() function. |
[in,out] | extraValues | Extra values that are passed as variadic parameters to read() member function of the protocol frame / stack. |
comms::ErrorStatus comms::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 handling function, or missing data is reported.
Similar to comms::processSingleWithDispatch(), but allows forcing a particular dispatch policy.
TDispatcher | A variant of comms::MsgDispatcher class. It's going to be used to dispatch message object into appropriate handling function instead of using comms::dispatchMsg() like comms::processSingleWithDispatch() does. |
[in,out] | bufIter | Iterator to input buffer. Passed by reference and is updated when buffer is iterated over. Number of consumed bytes cat be determined by calculating the distance between originally passed value and the one after function returns. |
[in] | len | Number of remaining bytes in input buffer. |
[in] | frame | Protocol frame / stack (see Transport Framing) that is used to process the raw input. |
[in,out] | msg | Smart pointer (see MsgPtr defintion of the Transport Framing) to message object to be allocated, or reference to actual message object (extending comms::MessageBase) when such is known. |
[in] | handler | Handler to handle message object when dispatched. The dispatch is performed via provded TDispatcher class (see comms::MsgDispatcher). |
[in,out] | extraValues | Extra values that are passed as variadic parameters to read() member function of the protocol frame / stack. |
auto comms::readIteratorFor | ( | TIter && | iter | ) | -> decltype(details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter))) |
Create and initialise iterator for message read.
TMessage | Type of message interface class or smart pointer to it. |
[in] | iter | Iterator value. |
auto comms::readIteratorFor | ( | TMessage && | msg, |
TIter && | iter | ||
) | -> decltype(details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter))) |
Create and initialise iterator for message read.
TMessage | Type of message interface class or smart pointer to it. |
[in] | msg | Unused message object helps detecting proper message type. |
[in] | iter | Iterator value. |
auto comms::writeIteratorFor | ( | TIter && | iter | ) | -> decltype(details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter))) |
Create and initialise iterator for message write.
TMessage | Type of message interface class or smart pointer to it. |
[in] | iter | Iterator value. |
auto comms::writeIteratorFor | ( | TMessage && | msg, |
TIter && | iter | ||
) | -> decltype(details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter))) |
Create and initialise iterator for message write.
TMessage | Type of message interface class or smart pointer to it. |
[in] | msg | Unused message object helps detecting proper message type. |
[in] | iter | Iterator value. |