31using namespace Messaging;
48 return static_cast<bool>(msg);
52template<
typename Message>
62 template <
class AnotherType>
66 , container_(rhs.container_)
73 template <
class AnotherType>
77 , container_(std::move(rhs.container_))
122 std::swap(rhs.size_, size_);
123 std::swap(rhs.container_, container_);
124 std::swap(rhs.message_, message_);
168 operator Message() noexcept
174 operator const Message() const noexcept
182 return container_.get();
190 message_ = Message();
196 return message_.toString();
201 template<
typename MessageT>
204 typename std::enable_if<!std::is_base_of<TagBased::Message, MessageT>::value,
MessageTemplateId>::type
207 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, MessageT>::value);
209 return MessageT::TemplateId;
212 template<
typename MessageT>
215 typename std::enable_if<std::is_base_of<TagBased::Message, MessageT>::value,
MessageTemplateId>::type
218 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, typename MessageT::Binary>::value);
220 return MessageT::Binary::TemplateId;
223 template<
typename MessageT>
225 typename std::enable_if<!std::is_base_of<TagBased::Message, MessageT>::value, MessageT>::type
226 typify(SbeMessage message)
228 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, MessageT>::value);
230 return Messaging::typify<MessageT>(message);
233 template<
typename MessageT>
235 typename std::enable_if<std::is_base_of<TagBased::Message, MessageT>::value, MessageT>::type
236 typify(SbeMessage message)
238 ONIXS_ICEBOE_STATIC_ASSERT(std::is_base_of<SbeMessage, typename MessageT::Binary>::value);
240 return MessageT(Messaging::typify<typename Message::Binary>(message));
243 template <
class AnotherType>
244 void fromAnotherType(
const MessagePtr<AnotherType>& rhs)
246 if(rhs->templateId() != getTemplateId<Message>())
247 throwWrongType(getTemplateId<Message>(), rhs->templateId());
249 message_ = this->typify<Message>(rhs);
254 Container container_;
264 , container_(std::move(container))
265 , message_(container_.get(), size_)
270template <
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.