OnixS C++ CME iLink 3 Binary Order Entry Handler  1.9.0
API Documentation
MessageSizeTraits.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/CME/iLink3/ABI.h>
25 
28 
29 
31 
32 #if defined(ONIXS_ILINK3_COMPILER_CXX_CONSTEXPR) && ONIXS_ILINK3_COMPILER_CXX_CONSTEXPR
33 
34 /// Assume the credentials filed of the message is empty.
35 template <typename Message>
36 struct HasEmptyCredentials
37 {
38  static constexpr bool UseCustomValue = true;
39 
40  static constexpr
41  UInt16 calculateMaxMessageSize()
42  {
43  return
44  Message::blockLength(Message::Schema::Version)
45  + MessageHeader::Size
46  + Message::getMinimalVariableFieldsSize(Message::Schema::Version);
47  }
48 };
49 
50 /// Assume the message has a constant size.
51 template <typename Message>
52 struct HasNoVariableFieldsOrGroups
53 {
54  static constexpr bool UseCustomValue = true;
55 
56  static constexpr
57  UInt16 calculateMaxMessageSize()
58  {
59  return
60  Message::blockLength(Message::Schema::Version)
61  + MessageHeader::Size;
62  }
63 };
64 
65 /// Traits for calculating the buffer size of a message.
66 template <typename Message> struct MaxMessageSizeTraits;
67 
68 /// \private
69 template <>
70 struct MaxMessageSizeTraits<Negotiate500> : HasEmptyCredentials<Negotiate500> {};
71 
72 /// \private
73 template <>
74 struct MaxMessageSizeTraits<Establish503> : HasEmptyCredentials<Establish503> {};
75 
76 /// \private
77 template <>
78 struct MaxMessageSizeTraits<Sequence506> : HasNoVariableFieldsOrGroups<Sequence506> {};
79 
80 /// \private
81 template <>
82 struct MaxMessageSizeTraits<Terminate507> : HasNoVariableFieldsOrGroups<Terminate507> {};
83 
84 /// \private
85 template <>
86 struct MaxMessageSizeTraits<Retransmission509> : HasNoVariableFieldsOrGroups<Retransmission509> {};
87 
88 #endif
89 
UInt16 UInt16
uInt16.
Definition: Fields.h:264
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_END
Definition: ABI.h:144
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:140