19#include "comms/details/tag.h"
28class DispatchMsgIdRetrieveHelper
32 template <
typename TMessage>
33 static typename TMessage::MsgIdParamType doGetId()
35 static_assert(TMessage::hasMsgIdType(),
"Message interface class must define its id type");
36 static_assert(!std::is_same<Tag<TMessage>, NoIdTag<> >::value,
"Must be able to retrieve ID");
38 return doGetIdInternal<TMessage>(Tag<TMessage>());
42 template <
typename... TParams>
43 using HasStaticIdTag = comms::details::tag::Tag1<>;
45 template <
typename... TParams>
46 using HasDynamicIdTag = comms::details::tag::Tag2<>;
48 template <
typename... TParams>
49 using NoIdTag = comms::details::tag::Tag3<>;
51 template <
typename TMessage,
typename...>
52 using DynamicCheckTag =
53 typename comms::util::LazyShallowConditional<
54 comms::isMessage<TMessage>() && TMessage::hasGetId()
60 template <
typename TMessage>
62 typename comms::util::LazyShallowConditional<
63 messageHasStaticNumId<TMessage>()
70 template <
typename TMessage,
typename... TParams>
71 static typename TMessage::MsgIdParamType doGetIdInternal(HasStaticIdTag<TParams...>)
73 static_assert(comms::isMessageBase<TMessage>(),
"Must be actual message");
74 static_assert(messageHasStaticNumId<TMessage>(),
"Message must define static numeric ID");
76 return TMessage::doGetId();
79 template <
typename TMessage,
typename... TParams>
80 static typename TMessage::MsgIdParamType doGetIdInternal(HasDynamicIdTag<TParams...>)
82 static_assert(comms::isMessage<TMessage>(),
"Must be actual message");
83 static_assert(TMessage::hasGetId(),
"Message interface must be able to return id polymorphically");
85 static const typename TMessage::MsgIdType Id = TMessage().getId();
90template <
typename TMessage>
91auto dispatchMsgGetMsgId() ->
decltype(DispatchMsgIdRetrieveHelper<>::template doGetId<TMessage>())
93 return DispatchMsgIdRetrieveHelper<>::template doGetId<TMessage>();
Contains various compiler related definitions.
Provides common base class for the custom messages with default implementation.
Contains definition of Message object interface and various base classes for custom messages.
Contains various tuple type manipulation classes and functions.
Main namespace for all classes / functions of COMMS library.
Replacement to some types from standard type_traits.