OnixS C++ FIX Engine  4.2.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 
28 
29 namespace OnixS {
30 namespace FIX {
31 /// Session's pluggable storage.
33 {
34 public:
35  /// Destructor.
36  virtual ~ISessionStorage() {};
37 
38  /// Clears the storage.
39  virtual void clear() = 0;
40 
41  /// Closes the storage.
42  virtual void close(bool keepSequenceNumbers, bool doBackup) = 0;
43 
44  /// Pointer to the native (tag=value) FIX Message.
47 
48  RawMessagePointer(const char * buffer, size_t length);
49 
50  /// @note the buffer is NOT owned by the RawMessagePointer.
51  const char * buffer_;
52 
53  size_t length_;
54  };
55 
56  /// Session Storage listener that is used to replay messages.
58  {
59  public:
60  /// @note FIX Engine/Session Storage does NOT manage the lifetime of this listener.
62 
63  ///
64  virtual void onReplayedMessage(const RawMessagePointer & pointer) = 0;
65  };
66 
67  /// Gets the messages that have been sent earlier.
68  /// Implementation should pass required messages one by one to ISessionStorageListener::onReplayedMessage(const RawMessagePointer& pointer) method.
69  /// It is possible to omit some or even all messages in requested range, in this case the Engine will automatically
70  /// generate appropriate \a SequenceReset-GapFill messages to replace omitted ones.
71  ///
72  /// @param beginSequenceNumber Sequence number of first message to resend.
73  ///
74  /// @param endSequenceNumber Sequence number of last message to resend.
75  ///
76  /// @param listener Requested messages have to be passed to the interface using ISessionStorageListener::onReplayedMessage method.
77  /// @note FIX Engine/Session Storage does NOT manage the lifetime of this listener.
78  virtual void getOutbound(SequenceNumber beginSequenceNumber, SequenceNumber endSequenceNumber,
79  ISessionStorageListener * listener) = 0;
80 
81  /// Returns the last inbound sequence number.
82  virtual SequenceNumber inSeqNum() = 0;
83 
84  /// Sets the last inbound sequence number.
85  virtual void inSeqNum(SequenceNumber messageSequenceNumber) = 0;
86 
87  /// Stores the given inbound message.
88  virtual void storeInbound(SequenceNumber messageSequenceNumber, const RawMessagePointer & pointer,
89  bool logMessage) = 0;
90 
91  /// Stores the given outgoing message.
92  virtual void storeOutbound(const Message &, const RawMessagePointer & pointer,
93  bool logMessage) = 0;
94 
95  /// Stores the given outgoing message.
96  virtual void storeOutbound(const SerializedMessage &, SequenceNumber sequenceNumber,
97  const RawMessagePointer & pointer, bool logMessage) = 0;
98 
99  /// Sets the session termination flag.
100  ///
101  /// @param terminated If 'true' then the session is terminated and its state information is not needed any more.
102  virtual void setSessionTerminationFlag(bool terminated) = 0;
103 
104  /// Returns the last outgoing sequence number.
105  virtual SequenceNumber outSeqNum() = 0;
106 
107  /// Sets the last outgoing sequence number.
108  virtual void outSeqNum(SequenceNumber messageSequenceNumber) = 0;
109 
110  /// Sets session creation time.
111  /// Implementation should store \a timestamp value. This value have to be returned without changes
112  /// by subsequent ISessionStorage::sessionCreationTime() calls.
113  /// @param timestamp Timestamp to store in the storage.
114  virtual void sessionCreationTime(Timestamp timestamp) = 0;
115 
116  /// Returns value stored by ISessionStorage::sessionCreationTime(Timestamp) call.
117  /// If the timestamp was never updated the method should return instance
118  /// of OnixS::FIX::Timestamp class created by default constructor.
119  ///
120  /// Code snippet below illustrate this approach:
121  /// @code
122  /// virtual Timestamp sessionCreationTime() {
123  ///
124  /// if (!creationTimeUpdated_)
125  /// return Timestamp();
126  ///
127  /// /* Return previously stored value. */
128  ///
129  /// }
130  /// @endcode
131  virtual Timestamp sessionCreationTime() = 0;
132 
133  /// Flushes all internal buffers
134  virtual void flush() = 0;
135 
136  /// Returns the number of sent messages that are available for resending on counterparty's Resend Request <2> message
137  virtual int resendingQueueSize() const = 0;
138 
139  /// Sets the number of sent messages that are available for resending on counterparty's Resend Request <2> message
140  virtual void resendingQueueSize(int value) = 0;
141 };
142 }
143 }
Session Storage listener that is used to replay messages.
unsigned int SequenceNumber
Alias for sequence mumber.
Session&#39;s pluggable storage.
Provides access to FIX fields from a serialized (tag=value) message.
Timestamps related functionality.
Definition: Timestamp.h:91
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Encapsulates operations over a FIX Message.
Definition: Message.h:49
Pointer to the native (tag=value) FIX Message.
virtual ~ISessionStorage()
Destructor.