OnixS C++ B3 BOE Binary Order Entry 1.3.0
API Documentation
Loading...
Searching...
No Matches
MaxMessageSize.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <OnixS/B3/BOE/ABI.h>
25
29
31
33
36
37#if defined(ONIXS_B3_BOE_CXX11)
38
40template <typename Message>
41struct MaxMessageSizeTraits
42{
43 static constexpr bool UseCustomValue = false;
44};
45
47template<typename Message>
48constexpr
50{
51 return
52 ONIXS_B3_BOE_ASSERT(Message::getMaxMessageSize(maxGroupItems) <= MaxB3BOEMessageSize),
53 static_cast<MessageSize>(Message::getMaxMessageSize(maxGroupItems));
54}
55
57template<typename Message>
58constexpr
59typename std::enable_if<MaxMessageSizeTraits<Message>::UseCustomValue, MessageSize>::type
61{
62 return
63 MaxMessageSizeTraits<Message>::calculateMaxMessageSize();
64}
65
67template<typename Message>
68constexpr
69typename std::enable_if<!MaxMessageSizeTraits<Message>::UseCustomValue, MessageSize>::type
70getMaxMessageSize(UInt8 maxGroupItems)
71{
72 return calculateMaxMessageSize<Message>(maxGroupItems);
73}
74
76template<typename Message, UInt8 MaxGroupItems>
77struct GetMaxMessageSize
78{
79 enum {Size = getMaxMessageSize<Message>(MaxGroupItems)};
80};
81
83template<typename Message>
84constexpr
85UInt16 getMinMessageSize()
86{
87 return
88 Message::blockLength(Message::Schema::Version)
89 + MessageHeader::Size
90 + Message::getMinimalVariableFieldsSize(Message::Schema::Version);
91}
92
94template<typename Message>
95struct GetMinMessageSize
96{
97 enum {Size = getMinMessageSize<Message>()};
98};
99
100#else
101
103template<typename Message, UInt8>
104struct GetMaxMessageSize
105{
106 enum {Size = MaxB3BOEMessageSize};
107};
108
110template<typename Message>
111struct GetMinMessageSize
112{
113 enum {Size = sizeof(SimpleOpenFramingHeader) + sizeof(MessageHeader) + 1};
114};
115
116#endif
117
#define ONIXS_B3_BOE_MESSAGING_NAMESPACE_END
Definition ABI.h:144
#define ONIXS_B3_BOE_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:140
#define ONIXS_B3_BOE_CONST_OR_CONSTEXPR
Definition Compiler.h:184
constexpr UInt16 MaxB3BOEMessageSize
Maximum supported message size.
constexpr std::enable_if< MaxMessageSizeTraits< Message >::UseCustomValue, MessageSize >::type getMaxMessageSize(UInt8)
Calculates the buffer size for a message with the given number of repeating group items.
UInt16 MessageSize
Message length type.
Definition Aliases.h:29
constexpr MessageSize calculateMaxMessageSize(UInt8 maxGroupItems)
Calculates the buffer size for a message with the given number of repeating group items.