OnixS C++ FIX Engine  4.8.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 /// Session's pluggable storage.
34 {
35 public:
36  /// Destructor.
38 
39  /// Clears the storage.
40  virtual void clear() = 0;
41 
42  /// Closes the storage.
43  ///
44  /// @param keepSequenceNumbers 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 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  /// 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  /// Session Storage listener that is used to replay messages.
62  {
63  public:
64  /// @note 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  /// Implementation should pass required messages one by one to ISessionStorageListener::onReplayedMessage(const RawMessagePointer& pointer) method.
73  /// It is possible to omit some or even all messages in requested range, in this case the Engine will automatically
74  /// generate appropriate \a SequenceReset-GapFill messages to replace omitted ones.
75  ///
76  /// @param beginSequenceNumber Sequence number of first message to resend.
77  /// @param endSequenceNumber Sequence number of last message to resend.
78  /// @param listener Requested messages have to be passed to the interface using ISessionStorageListener::onReplayedMessage method.
79  /// @note 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 messageSequenceNumber Sequence number of the inbound message.
91  /// @param pointer Raw buffer of the inbound message.
92  /// @param logMessage Flag to indicate whether it needs to store the content of the message in the session storage or not.
93  /// This parameter depends on the Session::logInboundMessages() and Session::inboundMessageLogFilter() settings.
94  virtual void storeInbound(SequenceNumber messageSequenceNumber, const RawMessagePointer & pointer, bool logMessage) = 0;
95 
96  /// Stores the given outgoing message.
97  /// It is called when the `messageMode` is set to `Message`.
98  ///
99  /// @param message Outgoing message.
100  /// @param pointer Raw buffer of the outgoing message.
101  /// @param logMessage Flag to indicate whether it needs to store the content of the message in the session storage or not.
102  /// This parameter depends on the Session::logOutboundMessages() and Session::outboundMessageLogFilter() settings.
103  virtual void storeOutbound(const Message & message, const RawMessagePointer & pointer, bool logMessage) = 0;
104 
105  /// Stores the given outgoing message.
106  /// It is called when the `messageMode` is set to `FlatMessage`.
107  ///
108  /// @param message Outgoing message.
109  /// @param sequenceNumber Sequence number of the outgoing message.
110  /// @param pointer Raw buffer of the outgoing message.
111  /// @param logMessage 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 FlatMessage & message, SequenceNumber sequenceNumber, const RawMessagePointer & pointer, bool logMessage) = 0;
114 
115  /// Sets the session termination flag.
116  ///
117  /// @param terminated If 'true' then the session is terminated and its state information is not needed any more.
118  /// It happens when the session is disconnected gracefully, and the `keepSequenceNumbers` parameter is false.
119  virtual void setSessionTerminationFlag(bool terminated) = 0;
120 
121  /// Returns the last outgoing sequence number.
122  virtual SequenceNumber outSeqNum() = 0;
123 
124  /// Sets the last outgoing sequence number.
125  virtual void outSeqNum(SequenceNumber messageSequenceNumber) = 0;
126 
127  /// Sets session creation time.
128  /// Implementation should store \a timestamp value. This value have to be returned without changes
129  /// by subsequent ISessionStorage::sessionCreationTime() calls.
130  ///
131  /// @param timestamp Timestamp to store in the storage.
132  virtual void sessionCreationTime(Timestamp timestamp) = 0;
133 
134  /// Returns value stored by ISessionStorage::sessionCreationTime(Timestamp) call.
135  /// If the timestamp was never updated the method should return instance
136  /// of OnixS::FIX::Timestamp class created by default constructor.
137  ///
138  /// Code snippet below illustrate this approach:
139  /// @code
140  /// virtual Timestamp sessionCreationTime() {
141  ///
142  /// if (!creationTimeUpdated_)
143  /// return Timestamp();
144  ///
145  /// /* Return previously stored value. */
146  ///
147  /// }
148  /// @endcode
149  virtual Timestamp sessionCreationTime() = 0;
150 
151  /// Flushes all internal buffers
152  virtual void flush() = 0;
153 
154  /// Returns the number of sent messages that are available for resending on counterparty's Resend Request <2> message
155  virtual size_t resendingQueueSize() const = 0;
156 
157  /// Sets the number of sent messages that are available for resending on counterparty's Resend Request <2> message
158  virtual void resendingQueueSize(size_t value) = 0;
159 
160  /// Warmup the storage
161  virtual void warmup(size_t /*messageSize*/) {}
162 };
163 }
164 }
Session Storage listener that is used to replay messages.
#define ONIXS_FIXENGINE_DEFAULT
Definition: Compiler.h:176
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Provides access to FIX fields from a flat (tag=value) message.
Definition: FlatMessage.h:75
Pointer to the native (tag=value) FIX Message.
Session&#39;s pluggable storage.
unsigned int SequenceNumber
Alias for sequence number.
Encapsulates operations over a FIX Message.
Definition: Message.h:49
Timestamps related functionality.
Definition: Timestamp.h:91
virtual void warmup(size_t)
Warmup the storage.