13 #include <type_traits>
20 #include "details/MsgFactoryOptionsParser.h"
21 #include "details/MsgFactoryBase.h"
85 template <
typename TMsgBase,
typename TAllMessages,
typename... TOptions>
86 class MsgFactory :
private details::MsgFactoryBase<TMsgBase, TAllMessages, TOptions...>
88 using Base = details::MsgFactoryBase<TMsgBase, TAllMessages, TOptions...>;
89 static_assert(TMsgBase::hasMsgIdType(),
90 "Usage of MsgFactory requires Message interface to provide ID type. "
91 "Use comms::option::def::MsgIdType option in message interface type definition.");
140 return Base::createMsg(
id, idx, reason);
157 return Base::createGenericMsg(
id, idx);
163 return Base::canAllocate();
171 return Base::msgCount(
id);
178 return Base::hasUniqueIds();
188 return Base::isDispatchPolymorphic();
198 return Base::isDispatchStaticBinSearch();
208 return Base::isDispatchLinearSwitch();
215 return ParsedOptions::HasInPlaceAllocation;
221 return ParsedOptions::HasSupportGenericMessage;
227 return ParsedOptions::HasForcedDispatch;
This file contains classes required for generic custom assertion functionality.
Contains definition of comms::MsgFactoryCreateFailureReason enum.
Contains various tuple type manipulation classes and functions.
This file contains various generic allocator classes that may be used to allocate objects using dynam...
Message factory class.
Definition: MsgFactory.h:87
typename Base::MsgIdType MsgIdType
Type of the message ID.
Definition: MsgFactory.h:104
bool canAllocate() const
Inquiry whether allocation is possible.
Definition: MsgFactory.h:161
static constexpr bool hasGenericMessageSupport()
Compile time inquiry whether factory supports comms::GenericMessage allocation.
Definition: MsgFactory.h:219
static constexpr bool isDispatchStaticBinSearch()
Compile time inquiry whether static binary search dispatch is generated internally to map message ID ...
Definition: MsgFactory.h:196
std::size_t msgCount(MsgIdParamType id) const
Get number of message types from AllMessages, that have the specified ID.
Definition: MsgFactory.h:169
static constexpr bool isDispatchLinearSwitch()
Compile time inquiry whether linear switch dispatch is generated internally to map message ID to actu...
Definition: MsgFactory.h:206
MsgPtr createMsg(MsgIdParamType id, unsigned idx=0U, CreateFailureReason *reason=nullptr) const
Create message object given the ID of the message.
Definition: MsgFactory.h:138
typename Base::ParsedOptions ParsedOptions
Parsed options.
Definition: MsgFactory.h:95
static constexpr bool hasUniqueIds()
Compile time inquiry whether all the message classes in the TAllMessages bundle have unique IDs.
Definition: MsgFactory.h:176
static constexpr bool hasInPlaceAllocation()
Compile time inquiry whether factory supports in-place allocation.
Definition: MsgFactory.h:213
MsgPtr createGenericMsg(MsgIdParamType id, unsigned idx=0U) const
Allocate and initialise comms::GenericMessage object.
Definition: MsgFactory.h:155
typename ParsedOptions::GenericMessage GenericMessage
type of generic message.
Definition: MsgFactory.h:119
static constexpr bool hasForcedDispatch()
Compile time inquiry whether factory has forced dispatch method.
Definition: MsgFactory.h:225
typename Base::Message Message
Type of the common base class of all the messages.
Definition: MsgFactory.h:98
typename Base::AllMessages AllMessages
All messages provided as template parameter to this class.
Definition: MsgFactory.h:112
typename Base::MsgIdParamType MsgIdParamType
Type of the message ID when passed as a parameter.
Definition: MsgFactory.h:101
static constexpr bool isDispatchPolymorphic()
Compile time inquiry whether polymorphic dispatch tables are generated internally to map message ID t...
Definition: MsgFactory.h:186
typename Base::MsgPtr MsgPtr
Smart pointer to Message which holds allocated message object.
Definition: MsgFactory.h:109
comms::option::def::MsgIdType< T > MsgIdType
Same as comms::option::def::MsgIdType.
Definition: options.h:1448
Main namespace for all classes / functions of COMMS library.
MsgFactoryCreateFailureReason
Definition: MsgFactoryCreateFailureReason.h:18