COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Related Symbols | List of all members
comms::MsgDispatcher< TOptions > Class Template Reference

#include "MsgDispatcher.h"

Detailed Description

template<typename... TOptions>
class comms::MsgDispatcher< TOptions >

An auxiliary class to force a particular way of dispatching message to its handler.

If not options are provided, the dispatching is performed by invocation of comms::dispatchMsg() function.

Template Parameters
TOptionsOptions to force a particular dispatch way. Supported ones are:

Public Types

using MsgDispatcherTag = typename ParsedOptions::ForcedDispatch
 Class detection tag.
 
using ParsedOptions = ParsedOptionsInternal
 Parsed Options.
 

Static Public Member Functions

template<typename TAllMessages , typename TMsg , typename THandler >
static auto dispatch (TMsg &&msg, THandler &&handler) -> decltype(dispatchInternal< TAllMessages >(msg, handler, Tag()))
 Dispatch message to its handler.
 
template<typename TAllMessages , typename TMsgId , typename TMsg , typename THandler >
static auto dispatch (TMsgId &&id, std::size_t idx, TMsg &msg, THandler &handler) -> decltype(dispatchInternal< TAllMessages >(std::forward< TMsgId >(id), idx, msg, handler, Tag()))
 Dispatch message to its handler.
 
template<typename TAllMessages , typename TMsgId , typename TMsg , typename THandler >
static auto dispatch (TMsgId &&id, TMsg &&msg, THandler &&handler) -> decltype(dispatchInternal< TAllMessages >(std::forward< TMsgId >(id), msg, handler, Tag()))
 Dispatch message to its handler.
 
template<typename TAllMessages >
static constexpr bool isDispatchLinearSwitch ()
 Compile time inquiry whether linear switch dispatch is generated internally to map message ID to actual type.
 
template<typename TAllMessages >
static constexpr bool isDispatchPolymorphic ()
 Compile time inquiry whether polymorphic dispatch tables are generated internally to map message ID to actual type.
 
template<typename TAllMessages >
static constexpr bool isDispatchStaticBinSearch ()
 Compile time inquiry whether static binary search dispatch is generated internally to map message ID to actual type.
 

Related Symbols

(Note that these are not member symbols.)

template<typename T >
constexpr bool isMsgDispatcher ()
 Compile time check whether the provided class is a variant of comms::MsgDispatcher.
 

Member Function Documentation

◆ dispatch() [1/3]

template<typename... TOptions>
template<typename TAllMessages , typename TMsg , typename THandler >
static auto comms::MsgDispatcher< TOptions >::dispatch ( TMsg &&  msg,
THandler &&  handler 
) -> decltype(dispatchInternal<TAllMessages>(msg, handler, Tag()))
static

Dispatch message to its handler.

Similar to other dispatch(), but suitable for cases when message interface class provides a way to polymorphically dispatch message object to its handler (see Polymorphic Dispatch Message for Handling) and/or ability to polymorphically retrieve message ID information (see Polymorphic Retrieval of Message ID) as well as requiring messages tuple does NOT contain message classes with the same ID value.

Template Parameters
TAllMessagesBundle (std::tuple) of all supported message classes
Parameters
[in]msgReference to message object.
[in]handlerReference to handler objectz
Returns
What the handle() member function(s) of the hander return.

◆ dispatch() [2/3]

template<typename... TOptions>
template<typename TAllMessages , typename TMsgId , typename TMsg , typename THandler >
static auto comms::MsgDispatcher< TOptions >::dispatch ( TMsgId &&  id,
std::size_t  idx,
TMsg &  msg,
THandler &  handler 
) -> decltype(dispatchInternal<TAllMessages>(std::forward<TMsgId>(id), idx, msg, handler, Tag()))
static

Dispatch message to its handler.

Uses comms::dispatchMsg(), comms::dispatchMsgPolymorphic(), comms::dispatchMsgStaticBinSearch(), or comms::dispatchMsgLinearSwitch() based on class definition option(s).

Template Parameters
TAllMessagesBundle (std::tuple) of all supported message classes
Parameters
[in]idID of the message.
[in]idxIndex (or offset) of the message among those having the same numeric ID in the TAllMessages.
[in]msgReference to message object.
[in]handlerReference to handler object
Returns
What the handle() member function(s) of the hander return.

◆ dispatch() [3/3]

template<typename... TOptions>
template<typename TAllMessages , typename TMsgId , typename TMsg , typename THandler >
static auto comms::MsgDispatcher< TOptions >::dispatch ( TMsgId &&  id,
TMsg &&  msg,
THandler &&  handler 
) -> decltype(dispatchInternal<TAllMessages>(std::forward<TMsgId>(id), msg, handler, Tag()))
static

Dispatch message to its handler.

Similar to other dispatch(), but suitable for cases when messages tuple does NOT contain message classes with the same ID value.

Template Parameters
TAllMessagesBundle (std::tuple) of all supported message classes
Parameters
[in]idID of the message.
[in]msgReference to message object.
[in]handlerReference to handler object
Returns
What the handle() member function(s) of the hander return.

◆ isDispatchLinearSwitch()

template<typename... TOptions>
template<typename TAllMessages >
static constexpr bool comms::MsgDispatcher< TOptions >::isDispatchLinearSwitch ( )
staticconstexpr

Compile time inquiry whether linear switch dispatch is generated internally to map message ID to actual type.

See also
Advanced Guide to Message Dispatching
isDispatchStaticBinSearch()
isDispatchLinearSwitch()

◆ isDispatchPolymorphic()

template<typename... TOptions>
template<typename TAllMessages >
static constexpr bool comms::MsgDispatcher< TOptions >::isDispatchPolymorphic ( )
staticconstexpr

Compile time inquiry whether polymorphic dispatch tables are generated internally to map message ID to actual type.

See also
Advanced Guide to Message Dispatching
isDispatchStaticBinSearch()
isDispatchLinearSwitch()

◆ isDispatchStaticBinSearch()

template<typename... TOptions>
template<typename TAllMessages >
static constexpr bool comms::MsgDispatcher< TOptions >::isDispatchStaticBinSearch ( )
staticconstexpr

Compile time inquiry whether static binary search dispatch is generated internally to map message ID to actual type.

See also
Advanced Guide to Message Dispatching
isDispatchPolymorphic()
isDispatchLinearSwitch()

The documentation for this class was generated from the following file: