21 #include <OnixS/CboeCFE/Trading/BOE/Compiler.h> 23 #if ONIXS_BATS_BOE_HAS_GATEWAY_EMULATOR 39 ONIXS_CBOE_CFE_BOE_API
40 ONIXS_BATS_BOE_NORETURN
43 template<
class Message>
44 Message typify(
const BinaryMessage& message)
46 return Message(message.binary(), message.binarySize());
50 template <
typename Message>
54 using Container = std::shared_ptr<UInt8>;
60 template <
class AnotherType>
61 explicit MessagePtr(
const MessagePtr<AnotherType>& rhs)
64 , container_(rhs.container_)
66 , seqNumber_(rhs.seqNumber_)
72 template <
class AnotherType>
73 explicit MessagePtr(MessagePtr<AnotherType>&& rhs)
76 , container_(
std::move(rhs.container_))
78 , seqNumber_(rhs.seqNumber_)
85 : type_(MessageType::Undefined)
89 , seqNumber_(SeqNumberTraits::InvalidValue)
93 MessagePtr(
const MessagePtr&) =
default;
94 MessagePtr& operator=(
const MessagePtr&) =
default;
97 MessagePtr(MessagePtr&& rhs) noexcept
104 MessagePtr& operator=(MessagePtr&& rhs) noexcept
116 bool valid() const noexcept
118 return static_cast<bool>(message_);
128 void swap(MessagePtr& rhs) noexcept
130 std::swap(rhs.type_, type_);
131 std::swap(rhs.size_, size_);
132 std::swap(rhs.container_, container_);
133 std::swap(rhs.message_, message_);
134 std::swap(rhs.seqNumber_, seqNumber_);
138 Message* operator->() noexcept
145 const Message* operator->() const noexcept
152 Message& operator*() noexcept
158 const Message& operator*() const noexcept
164 Message& message() noexcept
171 const Message& message() const noexcept
178 operator Message() noexcept
184 operator const Message() const noexcept
190 UInt8* buf() noexcept
192 return container_.get();
196 void reset() noexcept
201 message_ = Message();
205 std::string toString()
const 207 return toStr(message_);
218 Container c = container_;
224 template<
typename MessageT>
227 return MessageT::type();
230 template <
class AnotherType>
231 void fromAnotherType(
const MessagePtr<AnotherType>& rhs)
233 if(getType() != getMessageType<Message>())
234 throwWrongType(getMessageType<Message>(), getType());
236 message_ = typify<Message>(rhs);
242 Container container_;
246 template<
class T>
friend class MessagePtr;
253 , container_(
std::move(container))
254 , message_(container_.get(), size_)
255 , seqNumber_(seqNumber)
260 template <BOE::MessageType::Enum AnotherType>
261 MessagePtr<typename MessageTypeTraits<AnotherType>::MessageType> cast(
const MessagePtr<BinaryMessage>& ptr)
263 static_assert(std::is_base_of<BinaryMessage,
typename MessageTypeTraits<AnotherType>::MessageType>::value,
"");
264 return MessagePtr<typename MessageTypeTraits<AnotherType>::MessageType>(ptr);
267 using MessageBasePtr = MessagePtr<BinaryMessage>;
268 using NewOrderV2Ptr = MessagePtr<ConstantNewOrderV2>;
269 using ModifyOrderPtr = MessagePtr<ConstantModifyOrder>;
270 using CancelOrderPtr = MessagePtr<ConstantCancelOrder>;
271 using MassCancelOrderPtr = MessagePtr<ConstantMassCancelOrder>;
272 using PurgeOrdersPtr = MessagePtr<ConstantPurgeOrders>;
273 using QuoteUpdatePtr = MessagePtr<ConstantQuoteUpdate>;
274 using ResetRiskPtr = MessagePtr<ConstantResetRisk>;
275 using LoginRequestPtr = MessagePtr<ConstantLoginRequest>;
276 using LogoutRequestPtr = MessagePtr<ConstantLogoutRequest>;
277 using ClientHeartbeatPtr = MessagePtr<ConstantClientHeartbeat>;
279 typedef MessageBasePtr::Container PacketContainer;
Binary2 MessageSize
Aliases message length type.
ONIXS_CBOE_CFE_BOE_API void toStr(std::string &, const ConstantNewOrderV2 &)
Serializes object into string.