OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
MySessionStorage.cpp
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#include "MySessionStorage.h"
20
21#include <Common/Helpers.h>
22#include <Common/Listener.h>
23
24namespace Samples {
25namespace {
26
27 const char* begin(const NetworkMessage message) noexcept
28 {
29 return static_cast<const char*>(message.data());
30 }
31
32 const char* end(const NetworkMessage message) noexcept
33 {
34 return static_cast<const char*>(advanceByBytes(message.data(), message.size()));
35 }
36
37 void storeMessage(MySessionStorage::Messages & storage, const NetworkMessage message)
38 {
39 storage.push_back(MySessionStorage::Message(begin(message), end(message)));
40
41 if (!processTypified(message.message(), MessagePrinter()))
42 throw std::runtime_error("Unknown message type");
43 }
44}
45
47 inSeqNum_(1),
48 outSeqNum_(1),
49 id_(std::to_string(IdGenerator::newId())),
50 terminated_(false),
51 sessionCreationTime_()
52{}
53
54void MySessionStorage::close(bool doBackup)
55{
56 std::clog << "\nClose the session storage (doBackup=" << doBackup << ").\n";
57
58 inSeqNum_ = 1;
59 outSeqNum_ = 1;
60 terminated_ = false;
61 inboundMessages_.clear();
62 outboundMessages_.clear();
63}
64
65const std::string & MySessionStorage::id() const
66{
67 return id_;
68}
69
71{
72 return inSeqNum_;
73}
74
76{
77 std::clog << "\nSet inSeqNum to " << msgSeqNum << ".\n";
78 inSeqNum_ = msgSeqNum;
79}
80
82{
83 return outSeqNum_;
84}
85
87{
88 std::clog << "\nSet outSeqNum to " << msgSeqNum << ".\n";
89 outSeqNum_ = msgSeqNum;
90}
91
93{
94 return sessionCreationTime_;
95}
96
98{
99 std::clog << "\nSet sessionCreationTime to " << time << "\n";
100 sessionCreationTime_ = time;
101}
102
104{
105 std::clog << "\nStore inbound message:\n";
106 storeMessage(inboundMessages_, message);
107
108 inSeqNum_ = msgSeqNum;
109}
110
112{
113 std::clog << "\nStore outbound message:\n";
114 storeMessage(outboundMessages_, message);
115
116 outSeqNum_ = msgSeqNum;
117}
118
120{
121}
122
124{
125}
126
127}
The time point without the time-zone information.
Definition Time.h:470
void flush() override
Flushes all internal buffers.
void storeOutboundMessage(const NetworkMessage message, SeqNumber msgSeqNum, Timestamp messageSendingUtcTimestamp=Timestamp()) override
Logs the given outgoing message.
Timestamp sessionCreationTime() const override
std::vector< char > Message
void close(bool doBackup=false) override
Closes the storage.
void warmup(size_t, Timestamp) override
Warmup the storage.
SeqNumber outSeqNum() const override
SeqNumber inSeqNum() const override
std::list< Message > Messages
void storeInboundMessage(const NetworkMessage message, SeqNumber msgSeqNum, Timestamp messageReceivingUtcTimestamp=Timestamp()) override
Logs the given inbound message.
const std::string & id() const override
bool processTypified(SbeMessage binary, Processor &&processor)
Casts a given binary message according to template/type information and processes the cast messages b...
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
decltype(std::declval< const Messaging::SbeMessage & >().sequenceId()) SeqNumber
Definition Messaging.h:53