16#include "comms/details/MsgFactoryBase.h"
17#include "comms/details/MsgFactoryOptionsParser.h"
86template <
typename TMsgBase,
typename TAllMessages,
typename... TOptions>
87class MsgFactory :
private details::MsgFactoryBase<TMsgBase, TAllMessages, TOptions...>
89 using Base = details::MsgFactoryBase<TMsgBase, TAllMessages, TOptions...>;
90 static_assert(TMsgBase::hasMsgIdType(),
91 "Usage of MsgFactory requires Message interface to provide ID type. "
92 "Use comms::option::def::MsgIdType option in message interface type definition.");
141 return Base::createMsg(
id, idx, reason);
158 return Base::createGenericMsg(
id, idx);
164 return Base::canAllocate();
172 return Base::msgCount(
id);
179 return Base::hasUniqueIds();
189 return Base::isDispatchPolymorphic();
199 return Base::isDispatchStaticBinSearch();
209 return Base::isDispatchLinearSwitch();
216 return ParsedOptions::HasInPlaceAllocation;
222 return ParsedOptions::HasSupportGenericMessage;
228 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:88
typename Base::MsgIdType MsgIdType
Type of the message ID.
Definition MsgFactory.h:105
bool canAllocate() const
Inquiry whether allocation is possible.
Definition MsgFactory.h:162
static constexpr bool hasGenericMessageSupport()
Compile time inquiry whether factory supports comms::GenericMessage allocation.
Definition MsgFactory.h:220
static constexpr bool isDispatchStaticBinSearch()
Compile time inquiry whether static binary search dispatch is generated internally to map message ID ...
Definition MsgFactory.h:197
std::size_t msgCount(MsgIdParamType id) const
Get number of message types from AllMessages, that have the specified ID.
Definition MsgFactory.h:170
static constexpr bool isDispatchLinearSwitch()
Compile time inquiry whether linear switch dispatch is generated internally to map message ID to actu...
Definition MsgFactory.h:207
MsgPtr createMsg(MsgIdParamType id, unsigned idx=0U, CreateFailureReason *reason=nullptr) const
Create message object given the ID of the message.
Definition MsgFactory.h:139
typename Base::ParsedOptions ParsedOptions
Parsed options.
Definition MsgFactory.h:96
static constexpr bool hasUniqueIds()
Compile time inquiry whether all the message classes in the TAllMessages bundle have unique IDs.
Definition MsgFactory.h:177
static constexpr bool hasInPlaceAllocation()
Compile time inquiry whether factory supports in-place allocation.
Definition MsgFactory.h:214
MsgPtr createGenericMsg(MsgIdParamType id, unsigned idx=0U) const
Allocate and initialise comms::GenericMessage object.
Definition MsgFactory.h:156
typename ParsedOptions::GenericMessage GenericMessage
type of generic message.
Definition MsgFactory.h:120
static constexpr bool hasForcedDispatch()
Compile time inquiry whether factory has forced dispatch method.
Definition MsgFactory.h:226
typename Base::Message Message
Type of the common base class of all the messages.
Definition MsgFactory.h:99
typename Base::AllMessages AllMessages
All messages provided as template parameter to this class.
Definition MsgFactory.h:113
typename Base::MsgIdParamType MsgIdParamType
Type of the message ID when passed as a parameter.
Definition MsgFactory.h:102
static constexpr bool isDispatchPolymorphic()
Compile time inquiry whether polymorphic dispatch tables are generated internally to map message ID t...
Definition MsgFactory.h:187
typename Base::MsgPtr MsgPtr
Smart pointer to Message which holds allocated message object.
Definition MsgFactory.h:110
Main namespace for all classes / functions of COMMS library.
MsgFactoryCreateFailureReason
Definition MsgFactoryCreateFailureReason.h:20