35 template <
typename SbeMessageType>
36 inline static SbeMessageType createMessage(
39 return SbeMessageType(data, length, version);
45 return "FieldsInitPolicy";
53 template <
typename SbeMessageType>
54 inline static SbeMessageType createMessage(
57 return SbeMessageType(
64 return "FieldsNoInitPolicy";
68 template <
typename MessageType>
72 ONIXS_CONFLATEDTCP_STATIC_ASSERT((
73 IsBaseOf<SbeMessage, MessageType>::value));
78 SbeType::EncodedLength
87 : MessageType(data, length, version)
96 : MessageType(data, length, version)
104 : MessageType(data, length)
124 template <
typename,
size_t,
typename>
127 template <
typename,
size_t,
typename>
class HolderType,
129 size_t MaxMessageSize,
130 typename MessageInitializer>
133 const HolderType<MsgType, MaxMessageSize, MessageInitializer>& holder)
135 str +=
"MessageHolder[";
137 str +=
"BufferSize=";
138 toStr(str, holder.BufferSize);
140 str +=
", MessageInitializer=";
141 str += MessageInitializer::name();
144 toStr(str, *holder.header());
147 toStr(str, holder.message());
162 typename MessageTypeT,
163 size_t MaxMessageSize =
170 ONIXS_CONFLATEDTCP_STATIC_ASSERT_MSG(
172 "MaxMessageSize template parameter is too small");
174 ONIXS_CONFLATEDTCP_STATIC_ASSERT_MSG(
175 (MaxMessageSize >= GetMinMessageSize<SbeType>::Size),
176 "The buffer can not fit the message");
178 ONIXS_CONFLATEDTCP_STATIC_ASSERT_MSG(
180 "The buffer is too large.");
194 #ifdef ONIXS_CONFLATEDTCP_MEMCHECK_DEBUG 195 std::memset(buffer_, magicDebugValue, BufferSize);
199 message_ = MessageInitializer::template createMessage<MessageType>(
223 return header()->size();
283 message().calculateBinarySize();
285 assert(calculatedMessageSize <= MaxMessageSize);
288 calculatedMessageSize >=
289 SbeType::blockLength(message().version()) +
290 MessageHeaderBuilder::Size +
291 SbeType::getMinimalVariableFieldsSize(message().version()));
293 messageSize(calculatedMessageSize);
294 return calculatedMessageSize;
307 header()->setup(size + 2);
312 #ifdef ONIXS_CONFLATEDTCP_MEMCHECK_DEBUG 313 std::memset(buffer_, magicDebugValue, BufferSize);
318 assert(r.message_.calculateBinarySize() <= MaxMessageSize);
334 MessageType message_;
335 unsigned char buffer_[BufferSize];
339 template <
typename,
size_t,
typename>
class HolderType,
341 size_t MaxMessageSize,
342 typename MessageInitializer>
344 const HolderType<MsgType, MaxMessageSize, MessageInitializer>& holder)
352 template <
typename,
size_t,
typename>
class HolderType,
354 size_t MaxMessageSize,
355 typename MessageInitializer>
357 std::ostream& stream,
358 const HolderType<MsgType, MaxMessageSize, MessageInitializer>& rhs)
360 return stream <<
toStr(rhs);
363 #if defined(ONIXS_CONFLATEDTCP_CXX11) 366 typename MessageTypeT,
367 size_t MaxMessageSize =
370 using MessageHolders = std::vector<MessageHolder<MessageTypeT, MaxMessageSize, MessageInitializer> >;
const MessageType & message() const noexcept
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_END
The policy to create messages without initialized optional fields.
#define ONIXS_CONFLATEDTCP_NOTHROW
MessageType & message() noexcept
HeldAdapter(void *data, EncodedLength length, SbeMessage::NoInit)
Contains the SimpleOpenFramingHeader, the SBE message, and the data buffer.
#define ONIXS_CONFLATEDTCP_CONST_OR_CONSTEXPR
UInt16 bufferSize() const noexcept
const MessageType * operator->() const noexcept
MessageType * operator->() noexcept
std::ostream & operator<<(std::ostream &stream, const HolderType< MsgType, MaxMessageSize, MessageInitializer > &rhs)
std::string toString() const
const unsigned char * buffer() const noexcept
SbeType::EncodedLength EncodedLength
The policy to create messages with null-initialized optional fields.
#define ONIXS_CONFLATEDTCP_NODISCARD
UInt16 messageSize() const noexcept
HeldAdapter(void *data, EncodedLength length, SbeMessage::NoFieldsInit, SchemaVersion version)
SimpleOpenFramingHeader * header() noexcept
std::string toStr(const HolderType< MsgType, MaxMessageSize, MessageInitializer > &holder)
#define ONIXS_CONFLATEDTCP_DEFAULT
constexpr UInt16 MaxConflatedTcpMessageSize
Maximum supported message size.
#define ONIXS_CONFLATEDTCP_FINAL
MessageSize setHeader() noexcept
Calculates the binary size of the message and updates the Simple Open Framing Header accordingly...
MessageHeader::Version SchemaVersion
SBE-encoded data version type.
HeldAdapter< MessageTypeT > MessageType
Message type.
UInt16 MessageSize
Message length type.
std::vector< MessageHolder< MessageTypeT, MaxMessageSize, MessageInitializer > > MessageHolders
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_BEGIN
constexpr UInt8 DefaultMaxGroupItems
Default maximum number of repeating group items.
const SimpleOpenFramingHeader * header() const noexcept
MessageHolder(SchemaVersion version=SbeType::Schema::Version)
MessageHolder(const MessageHolder &r)
MessageHolder & operator=(const MessageHolder &r)
HeldAdapter(void *data, EncodedLength length, SbeMessage::NoInit, SbeMessage::NoCheck) noexcept