OnixS C++ CME MDP Conflated TCP Handler  1.3.1
API Documentation
SessionStorage.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
5 *
6 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
7 * and international copyright treaties.
8 *
9 * Access to and use of the software is governed by the terms of the applicable OnixS Software
10 * Services Agreement (the Agreement) and Customer end user license agreements granting
11 * a non-assignable, non-transferable and non-exclusive license to use the software
12 * for it's own data processing purposes under the terms defined in the Agreement.
13 *
14 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
15 * of this source code or associated reference material to any other location for further reproduction
16 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
17 *
18 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
19 * the terms of the Agreement is a violation of copyright law.
20 */
21 
27 
28 #include <string>
29 #include <vector>
30 
31 namespace OnixS {
32 namespace CME {
33 namespace ConflatedTCP {
34 
36 
37 /// Session Storage Type.
39 {
40  enum Enum
41  {
42  /// Undefined Session Storage.
43  Undefined = 0,
44 
45  /// File-based Session Storage.
47 
48  /// Asynchronous File-Based Session Storage.
50 
51  /// Memory-based Session Storage.
53 
54  /// Pluggable Session Storage
55  Pluggable
56  };
57 
58  ONIXS_CONFLATEDTCP_EXPORTED static Enum parse(const std::string &);
59 
60  /// \return the session storage type as a string.
61  ONIXS_CONFLATEDTCP_EXPORTED static const char * toString(SessionStorageType::Enum);
62 };
63 
64 /// Session's storage.
66 {
67 public:
68 
69  /// Destructor.
70  virtual ~SessionStorage() ONIXS_CONFLATEDTCP_DEFAULT;
71 
72  /// \return Storage Id.
73  virtual const std::string & id() const = 0;
74 
75  /// \return Universally Unique Identifier (UUID).
76  virtual UInt64 uuid() const = 0;
77 
78  /// Sets Universally Unique Identifier (UUID).
79  virtual void uuid(UInt64 value) = 0;
80 
81  /**
82  * \return The UUID from the previously Established session.
83  *
84  * - This can be the CME assigned default UUID=0 for messages published by CME before first Negotiation of customer at the beginning of the week.
85  * - This can be the last UUID as used by the customer from the previously Established session.
86  */
87  virtual UInt64 previousUuid() const = 0;
88 
89  /// Sets the UUID from the previously Established session.
90  virtual void previousUuid(UInt64 value) = 0;
91 
92  /// \return the expected sequence number of the next inbound message.
93  virtual SeqNumber inSeqNum() const = 0;
94 
95  /// Sets the expected sequence number of the next inbound message.
96  virtual void inSeqNum(SeqNumber msgSeqNum) = 0;
97 
98  /**
99  * \return the sequence number of the last business message published by CME with the PreviousUUID.
100  *
101  * If no business message was published, the value is zero.
102  */
103  virtual SeqNumber previousSeqNum() const = 0;
104 
105  /// Sets the sequence number of the last business message published by CME with the PreviousUUID.
106  virtual void previousSeqNum(SeqNumber msgSeqNum) = 0;
107 
108  /// \return the sequence number of the next outgoing message.
109  virtual SeqNumber outSeqNum() const = 0;
110 
111  /// Sets the sequence number of the next outgoing message.
112  virtual void outSeqNum(SeqNumber msgSeqNum) = 0;
113 
114  /// \return `true` if the logical session that used this storage was terminated and the storage can be cleaned up, otherwise - `false`.
115  virtual bool terminated() const = 0;
116 
117  /// Sets the Session Termination status.
118  virtual void terminated(bool terminated) = 0;
119 
120  /// \return the session creation time.
121  virtual Timestamp sessionCreationTime() const = 0;
122 
123  /// Sets the session creation time.
124  virtual void sessionCreationTime(Timestamp) = 0;
125 
126  /// Clears the storage.
127  virtual void clear() = 0;
128 
129  /// Closes the storage.
130  virtual void close(bool terminate = false, bool doBackup = false) = 0;
131 
132  /// Pointer to the SBE Message.
134  {
135  RawMessagePointer(const char *buffer = ONIXS_CONFLATEDTCP_NULLPTR, size_t length = 0)
136  : buffer_(buffer)
137  , length_(length)
138  {}
139 
140  /// \note the buffer is NOT owned by the RawMessagePointer.
141  const char *buffer_;
142 
143  size_t length_;
144  };
145 
146  /// Logs the given inbound message.
147  virtual void storeInboundMessage(const RawMessagePointer & rawMsg, SeqNumber msgSeqNum, bool isOriginal, Timestamp messageReceivingUtcTimestamp = Timestamp()) = 0;
148 
149  /// Logs the given outgoing message.
150  virtual void storeOutboundMessage(const RawMessagePointer & rawMsg, SeqNumber msgSeqNum, bool isOriginal = true, bool warmUp = false, Timestamp messageSendingUtcTimestamp = Timestamp()) = 0;
151 
152  /// Flushes all internal buffers.
153  virtual void flush() = 0;
154 };
155 
156 }
157 }
158 }
Messaging::UInt32 SeqNumber
Definition: Messaging.h:58
#define ONIXS_CONFLATEDTCP_EXPORTED
Definition: Compiler.h:187
Definition: Defines.h:40
The time point without the time-zone information.
Definition: Time.h:467
Asynchronous File-Based Session Storage.
RawMessagePointer(const char *buffer=ONIXS_CONFLATEDTCP_NULLPTR, size_t length=0)