OnixS C++ ICE Binary Order Entry Handler 1.0.0
API Documentation
Loading...
Searching...
No Matches
Composites.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/ICE/BOE/ABI.h>
24
30
32
33template <typename Callable>
34ONIXS_ICEBOE_FORCEINLINE
35auto convert(typename ArgType<Callable>::type value) noexcept(noexcept(Callable::Nothrow))
36 -> decltype(std::declval<Callable>()(std::declval<typename ArgType<Callable>::type>()))
37{
38 return Callable{}(value);
39}
40
41template <typename NullValue, typename Callable>
42auto convert(typename ArgType<Callable>::type value, OptionalTag) noexcept(noexcept(Callable::Nothrow))
43 -> SbeOptionalConverted<decltype(std::declval<Callable>()(std::declval<typename ArgType<Callable>::type>()))>
44{
45 using ReturnType = decltype(std::declval<Callable>()(std::declval<typename ArgType<Callable>::type>()));
46
47 if(value == NullValue::value())
49
50 return SbeOptionalConverted<ReturnType>(Callable{}(value));
51}
52
54
55
57{
58public:
60 enum { Size = 21 };
61
64
67
70
72 typedef UInt16 Version;
73
76
81
84 BlockLength blockLength() const noexcept
85 {
86 return blockLength_;
87 }
88
90 void blockLength(BlockLength value) noexcept
91 {
92 blockLength_ = value;
93 }
94
97 TemplateId templateId() const noexcept
98 {
99 return templateId_;
100 }
101
103 void templateId(TemplateId value) noexcept
104 {
105 templateId_ = value;
106 }
107
110 SchemaId schemaId() const noexcept
111 {
112 return schemaId_;
113 }
114
116 void schemaId(SchemaId value) noexcept
117 {
118 schemaId_ = value;
119 }
120
123 Version version() const noexcept
124 {
125 return version_;
126 }
127
129 void version(Version value) noexcept
130 {
131 version_ = value;
132 }
133
136 SequenceId sequenceId() const noexcept
137 {
138 return sequenceId_;
139 }
140
142 void sequenceId(SequenceId value) noexcept
143 {
144 sequenceId_ = value;
145 }
146
151 Timestamp sendTime() const noexcept(ticksToTimestamp::Nothrow)
152 {
153 return convert<ticksToTimestamp>(sendTime_);
154 }
155
159 void sendTime(Timestamp value) noexcept(timestampToTicks::Nothrow)
160 {
161 sendTime_ = convert<timestampToTicks>(value);
162 }
163
166 HeaderFlags headerFlags() const noexcept
167 {
168 return headerFlags_;
169 }
170
172 void headerFlags(HeaderFlags value) noexcept
173 {
174 headerFlags_ = value;
175 }
176
177private:
178 BlockLength blockLength_;
179 TemplateId templateId_;
180 SchemaId schemaId_;
181 Version version_;
182 SequenceId sequenceId_;
183 UTCTimestamp sendTime_;
184 HeaderFlags headerFlags_;
185};
186
187
190struct Data
191{
192public:
194 enum { Size = 2 };
195
197 typedef UInt16 Length;
198
200 typedef UInt8 VarData;
201
204 Length length() const noexcept
205 {
206 return length_;
207 }
208
210 void length(Length value) noexcept
211 {
212 length_ = value;
213 }
214
217 StrRef varData() const noexcept
218 {
219 return StrRef(reinterpret_cast<const Char*>(this) + Size, length());
220 }
221
223 void varData(StrRef value) noexcept
224 {
225 length(static_cast<Length>(value.size()));
226 if(value.data())
227 std::memcpy(reinterpret_cast<Char*>(this) + Size, value.data(), value.size());
228 }
229
232 Length binarySize() const noexcept
233 {
234 return Size + length();
235 }
236
237private:
238 Length length_;
239};
240
241
245{
246public:
248 enum { Size = 1 };
249
251 typedef UInt8 Length;
252
254 typedef Char VarData;
255
258 Length length() const noexcept
259 {
260 return length_;
261 }
262
264 void length(Length value) noexcept
265 {
266 length_ = value;
267 }
268
271 StrRef varData() const noexcept
272 {
273 return StrRef(reinterpret_cast<const Char*>(this) + Size, length());
274 }
275
277 void varData(StrRef value) noexcept
278 {
279 length(static_cast<Length>(value.size()));
280 if(value.data())
281 std::memcpy(reinterpret_cast<Char*>(this) + Size, value.data(), value.size());
282 }
283
286 Length binarySize() const noexcept
287 {
288 return Size + length();
289 }
290
291private:
292 Length length_;
293};
294
295
299{
300public:
302 enum { Size = 2 };
303
305 typedef UInt16 Length;
306
308 typedef Char VarData;
309
312 Length length() const noexcept
313 {
314 return length_;
315 }
316
318 void length(Length value) noexcept
319 {
320 length_ = value;
321 }
322
325 StrRef varData() const noexcept
326 {
327 return StrRef(reinterpret_cast<const Char*>(this) + Size, length());
328 }
329
331 void varData(StrRef value) noexcept
332 {
333 length(static_cast<Length>(value.size()));
334 if(value.data())
335 std::memcpy(reinterpret_cast<Char*>(this) + Size, value.data(), value.size());
336 }
337
340 Length binarySize() const noexcept
341 {
342 return Size + length();
343 }
344
345private:
346 Length length_;
347};
348
349
352{
353public:
355 enum { Size = 4 };
356
359
362
365 std::string
366 toString() const;
367
370 BlockLength blockLength() const noexcept
371 {
372 return blockLength_;
373 }
374
376 void blockLength(BlockLength value) noexcept
377 {
378 blockLength_ = value;
379 }
380
383 NumInGroup numInGroup() const noexcept
384 {
385 return numInGroup_;
386 }
387
389 void numInGroup(NumInGroup value) noexcept
390 {
391 numInGroup_ = value;
392 }
393
394private:
395 BlockLength blockLength_;
396 NumInGroup numInGroup_;
397};
398
399
402{
403public:
405 enum { Size = 4 };
406
409
412
415 std::string
416 toString() const;
417
420 BlockLength blockLength() const noexcept
421 {
422 return blockLength_;
423 }
424
426 void blockLength(BlockLength value) noexcept
427 {
428 blockLength_ = value;
429 }
430
433 NumInGroup numInGroup() const noexcept
434 {
435 return numInGroup_;
436 }
437
439 void numInGroup(NumInGroup value) noexcept
440 {
441 numInGroup_ = value;
442 }
443
444private:
445 BlockLength blockLength_;
446 NumInGroup numInGroup_;
447};
448
449
451
453
456{
457public:
459 enum { Size = 20 };
460
463
466
471
475 constexpr
476 OrderExecID() noexcept
477 : systemId_(0),
478 systemSequenceId_(0),
479 transactTime_(0)
480 {
481 }
482
485 : systemId_(systemId),
486 systemSequenceId_(systemSequenceId),
487 transactTime_(convert<timestampToTicks>(transactTime))
488 {
489 }
490
492 constexpr
494 : systemId_(systemId),
495 systemSequenceId_(systemSequenceId),
496 transactTime_(transactTime)
497 {
498 }
499
502 std::string
503 toString() const;
504
507 struct MemberTraits
508 {
509 enum { Count = 3 };
510
511 typedef SystemID FirstArgType;
512
513 typedef SystemSequenceID SecondArgType;
514
515 typedef UTCTimestamp ThirdArgType;
516 };
517
519 void serialize(void* addr) const noexcept
520 {
521 assert(addr);
522
523 std::memcpy(addr, &systemId_, sizeof(systemId_));
524 addr = advanceByBytes(addr, sizeof(systemId_));
525
526 std::memcpy(addr, &systemSequenceId_, sizeof(systemSequenceId_));
527 addr = advanceByBytes(addr, sizeof(systemSequenceId_));
528
529 std::memcpy(addr, &transactTime_, sizeof(transactTime_));
530 }
531
534 SystemID systemId() const noexcept
535 {
536 return systemId_;
537 }
538
540 void systemId(SystemID value) noexcept
541 {
542 systemId_ = value;
543 }
544
548 {
549 return systemSequenceId_;
550 }
551
554 {
555 systemSequenceId_ = value;
556 }
557
562 Timestamp transactTime() const noexcept(ticksToTimestamp::Nothrow)
563 {
564 return convert<ticksToTimestamp>(transactTime_);
565 }
566
570 void transactTime(Timestamp value) noexcept(timestampToTicks::Nothrow)
571 {
572 transactTime_ = convert<timestampToTicks>(value);
573 }
574
577 bool operator==(const OrderExecID& other) const noexcept
578 {
579 return
580 (this->systemId_ == other.systemId_) &&
581 (this->systemSequenceId_ == other.systemSequenceId_) &&
582 (this->transactTime_ == other.transactTime_);
583 }
584
587 bool operator!=(const OrderExecID& other) const noexcept
588 {
589 return !(*this == other);
590 }
591
592private:
593 SystemID systemId_;
594 SystemSequenceID systemSequenceId_;
595 UTCTimestamp transactTime_;
596};
597
598
601{
602public:
604 enum { Size = 16 };
605
610
612 typedef
613 IntegralConstant<Int64, -9223372036854775807LL-1>
615
620
622 typedef
625
629 constexpr
631 : originalSystemId_(NullOriginalSystemID::value()),
632 originalCreationTimestamp_(NullUTCTimestamp::value())
633 {
634 }
635
638 : originalSystemId_(originalSystemId),
639 originalCreationTimestamp_(convert<timestampToTicks>(originalCreationTimestamp))
640 {
641 }
642
644 constexpr
646 : originalSystemId_(originalSystemId),
647 originalCreationTimestamp_(originalCreationTimestamp)
648 {
649 }
650
653 std::string
654 toString() const;
655
658 struct MemberTraits
659 {
660 enum { Count = 2 };
661
662 typedef OriginalSystemID FirstArgType;
663
664 typedef UTCTimestamp SecondArgType;
665 };
666
668 void serialize(void* addr) const noexcept
669 {
670 assert(addr);
671
672 std::memcpy(addr, &originalSystemId_, sizeof(originalSystemId_));
673 addr = advanceByBytes(addr, sizeof(originalSystemId_));
674
675 std::memcpy(addr, &originalCreationTimestamp_, sizeof(originalCreationTimestamp_));
676 }
677
683 {
684 return originalSystemId_;
685 }
686
691 {
692 originalSystemId_ = value;
693 }
694
696 {
697 originalSystemId_ = NullOriginalSystemID();
698 }
699
703 auto originalCreationTimestamp() const noexcept(ticksToTimestamp::Nothrow)
704 {
706 originalCreationTimestamp_,
707 optional);
708 }
709
713 void originalCreationTimestamp(Timestamp value) noexcept(timestampToTicks::Nothrow)
714 {
715 originalCreationTimestamp_ = convert<timestampToTicks>(value);
716 }
717
719 {
720 originalCreationTimestamp_ = NullUTCTimestamp();
721 }
722
725 bool
727 const OriginalOrderID& other) const noexcept;
728
731 bool operator!=(const OriginalOrderID& other) const noexcept
732 {
733 return !(*this == other);
734 }
735
736private:
737 OriginalSystemID originalSystemId_;
738 UTCTimestamp originalCreationTimestamp_;
739};
740
741
744{
748
751 bool operator ==(const Value& other) const noexcept
752 {
753 return (
755 other.originalSystemId());
756 }
757
760 bool operator !=(const Value& other) const noexcept
761 {
762 return !(*this == other);
763 }
764
766 constexpr
767 operator Value() const noexcept
768 {
769 return Value();
770 }
771
773 constexpr
774 Value operator()() const noexcept
775 {
776 return Value();
777 }
778
780 constexpr
781 static Value value() noexcept
782 {
783 return Value();
784 }
785};
786
787inline bool OriginalOrderID::operator==(const OriginalOrderID& other) const noexcept
788{
789 if((NullOriginalOrderID() == *this) &&
790 (NullOriginalOrderID() == other))
791 return true;
792
793 return
794 (this->originalSystemId_ == other.originalSystemId_) &&
795 (this->originalCreationTimestamp_ == other.originalCreationTimestamp_);
796}
797
798
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:102
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
Definition ABI.h:106
#define ONIXS_ICEBOE_DATA_PACKING_END
Definition Compiler.h:168
#define ONIXS_ICEBOE_NODISCARD
Definition Compiler.h:154
#define ONIXS_ICEBOE_DATA_PACKING_BEGIN(alignment)
Definition Compiler.h:167
NumInGroup numInGroup() const noexcept
Definition Composites.h:383
void numInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition Composites.h:389
void blockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition Composites.h:376
UInt16 BlockLength
Type alias for the BlockLength.
Definition Composites.h:358
UInt16 NumInGroup
Type alias for the NumInGroup.
Definition Composites.h:361
BlockLength blockLength() const noexcept
Definition Composites.h:370
void numInGroup(NumInGroup value) noexcept
Sets the numInGroup field.
Definition Composites.h:439
void blockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition Composites.h:426
UInt16 BlockLength
Type alias for the BlockLength.
Definition Composites.h:408
UInt16 NumInGroup
Type alias for the NumInGroup.
Definition Composites.h:411
Message identifiers and length of message root.
Definition Composites.h:57
Timestamp sendTime() const noexcept(ticksToTimestamp::Nothrow)
Definition Composites.h:151
SchemaId schemaId() const noexcept
Definition Composites.h:110
void headerFlags(HeaderFlags value) noexcept
Sets the headerFlags field.
Definition Composites.h:172
void blockLength(BlockLength value) noexcept
Sets the blockLength field.
Definition Composites.h:90
UInt64 UTCTimestamp
Type alias for the SendTime.
Definition Composites.h:80
void templateId(TemplateId value) noexcept
Sets the templateId field.
Definition Composites.h:103
UInt16 SchemaId
Type alias for the SchemaId.
Definition Composites.h:69
UInt16 BlockLength
Type alias for the BlockLength.
Definition Composites.h:63
UInt16 TemplateId
Type alias for the TemplateId.
Definition Composites.h:66
void sequenceId(SequenceId value) noexcept
Sets the sequenceId field.
Definition Composites.h:142
SequenceId sequenceId() const noexcept
Definition Composites.h:136
void sendTime(Timestamp value) noexcept(timestampToTicks::Nothrow)
Sets the sendTime field.
Definition Composites.h:159
BlockLength blockLength() const noexcept
Definition Composites.h:84
void schemaId(SchemaId value) noexcept
Sets the schemaId field.
Definition Composites.h:116
UInt16 Version
Type alias for the Version.
Definition Composites.h:72
void version(Version value) noexcept
Sets the version field.
Definition Composites.h:129
HeaderFlags headerFlags() const noexcept
Definition Composites.h:166
TemplateId templateId() const noexcept
Definition Composites.h:97
UInt32 SequenceId
Type alias for the SequenceId.
Definition Composites.h:75
void transactTime(Timestamp value) noexcept(timestampToTicks::Nothrow)
Sets the transactTime field.
Definition Composites.h:570
bool operator==(const OrderExecID &other) const noexcept
Compares encoded data.
Definition Composites.h:577
Int32 SystemSequenceID
Type alias for the SystemSequenceID.
Definition Composites.h:465
OrderExecID(SystemID systemId, SystemSequenceID systemSequenceId, Timestamp transactTime) noexcept(timestampToTicks::Nothrow)
Initializes fields with the provided values.
Definition Composites.h:484
SystemSequenceID systemSequenceId() const noexcept
Definition Composites.h:547
Timestamp transactTime() const noexcept(ticksToTimestamp::Nothrow)
Definition Composites.h:562
SystemID systemId() const noexcept
Definition Composites.h:534
UInt64 UTCTimestamp
Type alias for the TransactTime.
Definition Composites.h:470
void systemId(SystemID value) noexcept
Sets the systemID field.
Definition Composites.h:540
void systemSequenceId(SystemSequenceID value) noexcept
Sets the systemSequenceID field.
Definition Composites.h:553
Int64 SystemID
Type alias for the SystemID.
Definition Composites.h:462
void serialize(void *addr) const noexcept
Serializes to a data buffer.
Definition Composites.h:519
constexpr OrderExecID() noexcept
Default constructor.
Definition Composites.h:476
constexpr OrderExecID(SystemID systemId, SystemSequenceID systemSequenceId, UTCTimestamp transactTime) noexcept
Initializes fields with the provided values.
Definition Composites.h:493
bool operator!=(const OrderExecID &other) const noexcept
Compares encoded data.
Definition Composites.h:587
void originalSystemId(OriginalSystemID value) noexcept
Sets the originalSystemID field.
Definition Composites.h:690
void originalCreationTimestamp(Timestamp value) noexcept(timestampToTicks::Nothrow)
Sets the originalCreationTimestamp field.
Definition Composites.h:713
bool operator!=(const OriginalOrderID &other) const noexcept
Compares encoded data.
Definition Composites.h:731
IntegralConstant< Int64, -9223372036854775807LL-1 > NullOriginalSystemID
Null value for an optional OriginalSystemID field.
Definition Composites.h:614
IntegralConstant< UInt64, 0ULL > NullUTCTimestamp
Null value for an optional UTCTimestamp field.
Definition Composites.h:624
UInt64 UTCTimestamp
Type alias for the OriginalCreationTimestamp.
Definition Composites.h:619
auto originalCreationTimestamp() const noexcept(ticksToTimestamp::Nothrow)
Definition Composites.h:703
bool operator==(const OriginalOrderID &other) const noexcept
Compares encoded data.
Definition Composites.h:787
constexpr OriginalOrderID(OriginalSystemID originalSystemId, UTCTimestamp originalCreationTimestamp) noexcept
Initializes fields with the provided values.
Definition Composites.h:645
void originalCreationTimestamp(NullOpt) noexcept
Definition Composites.h:718
void serialize(void *addr) const noexcept
Serializes to a data buffer.
Definition Composites.h:668
constexpr OriginalOrderID() noexcept
Default constructor.
Definition Composites.h:630
OriginalSystemID originalSystemId() const noexcept
Definition Composites.h:682
OriginalOrderID(OriginalSystemID originalSystemId, Timestamp originalCreationTimestamp) noexcept(timestampToTicks::Nothrow)
Initializes fields with the provided values.
Definition Composites.h:637
Int64 OriginalSystemID
Type alias for the OriginalSystemID.
Definition Composites.h:609
static ONIXS_ICEBOE_FORCEINLINE constexpr SbeOptionalConverted< T > null() noexcept
Definition SbeOptional.h:70
The time point without the time-zone information.
Definition Time.h:470
ONIXS_ICEBOE_WRAP_F(ticksToTimestampImpl) ticksToTimestamp
Definition Fields.h:1044
UInt64 UTCTimestamp
Nanoseconds since Unix epoch (January 1st, 1970).
Definition Fields.h:50
char Char
Character type alias.
Definition String.h:31
MessageHeader MessageHeaderBuilder
Definition Composites.h:450
ONIXS_ICEBOE_FORCEINLINE Type * advanceByBytes(Type *pointer, ptrdiff_t distance) noexcept
Advances the pointer to a given offset (distance) in bytes.
Definition Memory.h:110
HeaderFlags
HeaderFlags type.
Definition Fields.h:923
ONIXS_ICEBOE_WRAP_F(timestampToTicksImpl) timestampToTicks
Definition Fields.h:1050
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
MessageHeader::SchemaId SchemaId
MessageHeader::SequenceId SequenceId
bool operator==(const Decimal &left, const Decimal &right) noexcept
constexpr OptionalTag optional
ONIXS_ICEBOE_FORCEINLINE auto convert(typename ArgType< Callable >::type value) noexcept(noexcept(Callable::Nothrow)) -> decltype(std::declval< Callable >()(std::declval< typename ArgType< Callable >::type >()))
Definition Composites.h:35
StrRef varData() const noexcept
Definition Composites.h:217
Length binarySize() const noexcept
Definition Composites.h:232
void length(Length value) noexcept
Sets the length.
Definition Composites.h:210
void varData(StrRef value) noexcept
Sets the varData field.
Definition Composites.h:223
Length length() const noexcept
Definition Composites.h:204
Null values definition for optional OriginalOrderID field.
Definition Composites.h:744
constexpr Value operator()() const noexcept
Definition Composites.h:774
static constexpr Value value() noexcept
Definition Composites.h:781
OriginalOrderID Value
Aliases the type whose null value traits are exposed by the given class.
Definition Composites.h:747
Length binarySize() const noexcept
Definition Composites.h:340
void length(Length value) noexcept
Sets the length.
Definition Composites.h:318
void varData(StrRef value) noexcept
Sets the varData field.
Definition Composites.h:331
StrRef varData() const noexcept
Definition Composites.h:271
Length binarySize() const noexcept
Definition Composites.h:286
void length(Length value) noexcept
Sets the length.
Definition Composites.h:264
void varData(StrRef value) noexcept
Sets the varData field.
Definition Composites.h:277