OnixS C++ FIX Engine  4.12.0
API Documentation
ISessionStorage.h
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 
20 #pragma once
21 
22 #include <string>
23 #include <vector>
24 
29 
30 namespace OnixS {
31 namespace FIX {
32 /// The session's pluggable storage.
34 {
35 public:
36  /// The destructor.
38 
39  /// Clears the storage.
40  virtual void clear() = 0;
41 
42  /// Closes the storage.
43  ///
44  /// @param keepSequenceNumbers The flag to indicate if it needs to clear sequence numbers on close or not. It corresponds to the same parameter in the Session's constructor.
45  /// @param doBackup The flag to indicate if it needs to back up the stored data. It is true, when the Session::resetLocalSequenceNumbers() method is called.
46  virtual void close(bool keepSequenceNumbers, bool doBackup) = 0;
47 
48  /// The pointer to the native (tag=value) FIX Message.
51 
52  RawMessagePointer(const char * buffer, size_t length);
53 
54  /// @note The buffer is NOT owned by the RawMessagePointer.
55  const char * buffer_;
56 
57  size_t length_;
58  };
59 
60  /// The Session Storage listener that is used to replay messages.
62  {
63  public:
64  /// @note The FIX Engine/Session Storage does NOT manage the lifetime of this listener.
66 
67  /// The Implementation should pass required messages one by one to this method.
68  virtual void onReplayedMessage(const RawMessagePointer & pointer) = 0;
69  };
70 
71  /// Gets the messages that have been sent earlier.
72  /// The implementation should pass required messages one by one to the ISessionStorageListener::onReplayedMessage(const RawMessagePointer& pointer) method.
73  /// It is possible to omit some or even all messages in the requested range, in this case the Engine will automatically
74  /// generate appropriate \a SequenceReset-GapFill messages to replace omitted ones.
75  ///
76  /// @param beginSequenceNumber The sequence number of first message to resend.
77  /// @param endSequenceNumber the sequence number of last message to resend.
78  /// @param listener Requested messages have to be passed to the interface using the ISessionStorageListener::onReplayedMessage method.
79  /// @note The FIX Engine/Session Storage does NOT manage the lifetime of this listener.
80  virtual void getOutbound(SequenceNumber beginSequenceNumber, SequenceNumber endSequenceNumber, ISessionStorageListener * listener) = 0;
81 
82  /// Returns the last inbound sequence number.
83  virtual SequenceNumber inSeqNum() = 0;
84 
85  /// Sets the last inbound sequence number.
86  virtual void inSeqNum(SequenceNumber messageSequenceNumber) = 0;
87 
88  /// Stores the given inbound message.
89  ///
90  /// @param message The incoming message.
91  /// @param sequenceNumber The sequence number of the inbound message.
92  /// @param pointer The raw buffer of the inbound message.
93  /// @param logMessage The flag to indicate whether it needs to store the content of the message in the session storage or not.
94  /// This parameter depends on the Session::logInboundMessages() and Session::inboundMessageLogFilter() settings.
95  virtual void storeInbound(const Message & message, SequenceNumber sequenceNumber, const RawMessagePointer & pointer, bool logMessage) = 0;
96 
97  /// Stores the given inbound message.
98  ///
99  /// @param message The incoming message.
100  /// @param sequenceNumber The sequence number of the inbound message.
101  /// @param pointer The raw buffer of the inbound message.
102  /// @param logMessage The flag to indicate whether it needs to store the content of the message in the session storage or not.
103  /// This parameter depends on the Session::logInboundMessages() and Session::inboundMessageLogFilter() settings.
104  virtual void storeInbound(const FlatMessage & message, SequenceNumber sequenceNumber, const RawMessagePointer & pointer, bool logMessage) = 0;
105 
106  /// Stores the given outgoing message.
107  /// It is called when the `messageMode` is set to `Message`.
108  ///
109  /// @param message The outgoing message.
110  /// @param pointer The raw buffer of the outgoing message.
111  /// @param logMessage The flag to indicate whether it needs to store the content of the message in the session storage or not.
112  /// This parameter depends on the Session::logOutboundMessages() and Session::outboundMessageLogFilter() settings.
113  virtual void storeOutbound(const Message & message, const RawMessagePointer & pointer, bool logMessage) = 0;
114 
115  /// Stores the given outgoing message.
116  /// It is called when the `messageMode` is set to `FlatMessage`.
117  ///
118  /// @param message The outgoing message.
119  /// @param sequenceNumber The sequence number of the outgoing message.
120  /// @param pointer The raw buffer of the outgoing message.
121  /// @param logMessage The flag to indicate whether it needs to store the content of the message in the session storage or not.
122  /// This parameter depends on the Session::logOutboundMessages() and Session::outboundMessageLogFilter() settings.
123  virtual void storeOutbound(const FlatMessage & message, SequenceNumber sequenceNumber, const RawMessagePointer & pointer, bool logMessage) = 0;
124 
125  /// Sets the session termination flag.
126  ///
127  /// @param terminated If 'true' then the session is terminated and its state information is not needed any more.
128  /// It happens when the session is disconnected gracefully, and the `keepSequenceNumbers` parameter is false.
129  virtual void setSessionTerminationFlag(bool terminated) = 0;
130 
131  /// Returns the last outgoing sequence number.
132  virtual SequenceNumber outSeqNum() = 0;
133 
134  /// Sets the last outgoing sequence number.
135  virtual void outSeqNum(SequenceNumber messageSequenceNumber) = 0;
136 
137  /// Sets the session creation time.
138  /// The implementation should store the \a timestamp value. This value have to be returned without changes
139  /// by subsequent ISessionStorage::sessionCreationTime() calls.
140  ///
141  /// @param timestamp The timestamp to store in the storage.
142  virtual void sessionCreationTime(Timestamp timestamp) = 0;
143 
144  /// Returns a value stored by the ISessionStorage::sessionCreationTime(Timestamp) call.
145  /// If the timestamp was never updated the method should return an instance
146  /// of the OnixS::FIX::Timestamp class created by the default constructor.
147  ///
148  /// The code snippet below illustrate this approach:
149  ///
150  /// virtual Timestamp sessionCreationTime() {
151  ///
152  /// if (!creationTimeUpdated_)
153  /// return Timestamp();
154  ///
155  /// /* Return previously stored value. */
156  ///
157  /// }
158  ///
159  virtual Timestamp sessionCreationTime() = 0;
160 
161  /// Flushes all internal buffers
162  virtual void flush() = 0;
163 
164  /// Returns the number of sent messages that are available for resending on counterparty's Resend Request <2> message
165  virtual size_t resendingQueueSize() const = 0;
166 
167  /// Sets the number of sent messages that are available for resending on counterparty's Resend Request <2> message
168  virtual void resendingQueueSize(size_t value) = 0;
169 
170  /// Warm ups the storage
171  virtual void warmup(size_t /*messageSize*/) {}
172 };
173 }
174 }
virtual void storeOutbound(const Message &message, const RawMessagePointer &pointer, bool logMessage)=0
Stores the given outgoing message.
virtual void close(bool keepSequenceNumbers, bool doBackup)=0
Closes the storage.
virtual void storeInbound(const Message &message, SequenceNumber sequenceNumber, const RawMessagePointer &pointer, bool logMessage)=0
Stores the given inbound message.
The Session Storage listener that is used to replay messages.
virtual void flush()=0
Flushes all internal buffers.
#define ONIXS_FIXENGINE_DEFAULT
Definition: Compiler.h:176
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
virtual ~ISessionStorage() ONIXS_FIXENGINE_DEFAULT
The destructor.
Provides an access to FIX fields from a flat (tag=value) message.
Definition: FlatMessage.h:109
virtual size_t resendingQueueSize() const =0
Returns the number of sent messages that are available for resending on counterparty&#39;s Resend Request...
virtual void clear()=0
Clears the storage.
virtual void warmup(size_t)
Warm ups the storage.
The pointer to the native (tag=value) FIX Message.
virtual void getOutbound(SequenceNumber beginSequenceNumber, SequenceNumber endSequenceNumber, ISessionStorageListener *listener)=0
Gets the messages that have been sent earlier.
virtual void setSessionTerminationFlag(bool terminated)=0
Sets the session termination flag.
The session&#39;s pluggable storage.
unsigned int SequenceNumber
Alias for the sequence number.
Encapsulates operations over a FIX Message.
Definition: Message.h:49
virtual SequenceNumber outSeqNum()=0
Returns the last outgoing sequence number.
The timestamps related functionality.
Definition: Timestamp.h:91
virtual SequenceNumber inSeqNum()=0
Returns the last inbound sequence number.
class ONIXS_FIXENGINE_API OnixS::FIX::ISessionStorage sessionCreationTime()=0