31using namespace Messaging;
46 return static_cast<bool>(msg);
50template<
typename Message>
60 template <
class AnotherType>
64 , container_(rhs.container_)
71 template <
class AnotherType>
75 , container_(std::move(rhs.container_))
120 std::swap(rhs.size_, size_);
121 std::swap(rhs.container_, container_);
122 std::swap(rhs.message_, message_);
166 operator Message() noexcept
172 operator const Message() const noexcept
180 return container_.get();
188 message_ = Message();
194 return message_.toString();
199 template<
typename MessageT>
200 static constexpr typename std::enable_if<!std::is_base_of<TagBased::Message, MessageT>::value,
MessageTemplateId>::type
203 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, MessageT>::value);
205 return MessageT::TemplateId;
208 template<
typename MessageT>
209 static constexpr typename std::enable_if<std::is_base_of<TagBased::Message, MessageT>::value,
MessageTemplateId>::type
212 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, typename MessageT::Binary>::value);
214 return MessageT::Binary::TemplateId;
217 template<
typename MessageT>
218 static typename std::enable_if<!std::is_base_of<TagBased::Message, MessageT>::value, MessageT>::type
219 typify(SbeMessage message)
221 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, MessageT>::value);
223 return Messaging::typify<MessageT>(message);
226 template<
typename MessageT>
227 static typename std::enable_if<std::is_base_of<TagBased::Message, MessageT>::value, MessageT>::type
228 typify(SbeMessage message)
230 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, typename MessageT::Binary>::value);
232 return MessageT(Messaging::typify<typename Message::Binary>(message));
235 template <
class AnotherType>
236 void fromAnotherType(
const MessagePtr<AnotherType>& rhs)
238 if(rhs->templateId() != getTemplateId<Message>())
239 throwWrongType(getTemplateId<Message>(), rhs->templateId());
241 message_ = this->typify<Message>(rhs);
246 Container container_;
256 , container_(std::move(container))
257 , message_(container_.get(), size_)
262template <
typename AnotherType,
typename BaseType>
#define ONIXS_ICEBOE_NAMESPACE_BEGIN
#define ONIXS_ICEBOE_NAMESPACE_END
#define ONIXS_ICEBOE_EXPORTED
const Message & message() const noexcept
const Message & operator*() const noexcept
MessagePtr(MessagePtr< AnotherType > &&rhs)
Creates from the given type.
std::string toString() const
const Message * operator->() const noexcept
Message & message() noexcept
MessagePtr(const MessagePtr &)=default
Message * operator->() noexcept
MessagePtr()
Creates an empty message container.
MessagePtr(const MessagePtr< AnotherType > &rhs)
Create from another type.
void swap(MessagePtr &rhs) noexcept
bool valid() const noexcept
MessagePtr(Container &&, MessageSize)
Creates from the given memory block.
MessagePtr & operator=(MessagePtr &&rhs) noexcept
MessagePtr & operator=(const MessagePtr &)=default
Message & operator*() noexcept
std::shared_ptr< UInt8 > Container
MessagePtr(MessagePtr &&rhs) noexcept
void reset()
Resets the message.
constexpr std::enable_if<!details::HasMemberTraits< Value >::value, size_t >::type size() noexcept
UInt16 MessageSize
Message length type.
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.
bool isMessageValid(const SbeMessage msg) noexcept
void throwWrongType(UInt16, UInt16)
MessagePtr< AnotherType > cast(const MessagePtr< BaseType > &ptr)
Tries to cast to another type.