OnixS C++ MTS Cash SDP Handler  1.7.0
API documentation
Handler.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4 *
5 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6 * and international copyright treaties.
7 *
8 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
9 * Services Agreement (the Agreement) and Customer end user license agreements granting
10 * a non-assignable, non-transferable and non-exclusive license to use the software
11 * for it's own data processing purposes under the terms defined in the Agreement.
12 *
13 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14 * of this source code or associated reference material to any other location for further reproduction
15 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20 
21 #include "OnixS/MTS/Cash/SDP/ABI.h"
27 
28 namespace OnixS {
29 namespace Mts {
30 namespace Cash {
31 namespace SDP {
32 
33 class Class;
34 struct ReplayOptions;
35 
36 /// OnixS MTS Cash/SDP Handler
37 ///
38 class ONIXS_MTS_CASH_SDP_API Handler
39 {
40 public:
41  /// Performs instance initialization.
42  /// @param settings defines values for various options
43  /// which affect handler behavior like enabling logging
44  /// during execution of the handler.
45  Handler (const HandlerSettings& settings);
46 
47  virtual ~Handler();
48 
49  /// Establishes the connection.
50  ///
51  /// @note Blocks until the logon reply is received.
52  ///
53  /// @note Should be called only when Handler is disconnected.
54  ///
55  /// @param hostName Hostname to connect to.
56  ///
57  /// @param port Port number to connect to.
58  ///
59  /// @param logon Initial logon message parameters.
60  ///
61  /// @param localNetworkInterface Local network interface.
62  ///
63  /// @throw std::exception Cannot set the local network interface.
64  /// @throw std::exception Cannot connect to hostname on port.
65  /// @throw std::exception Cannot configure size of receive buffer for the socket.
66  /// @throw std::exception Cannot configure size of send buffer for the socket.
67  /// @throw OperationException Invalid argument is given.
68  void connect (const ConnectionSettings& connectionSettings, const LogonSettings& logonSettings, const std::string& hostName, UInt16 port, const std::string& localNetworkInterface = "");
69 
70  /// Force session disconnect.
71  ///
72  /// @note Blocks until the Session Logout procedure is finished.
73  void disconnect ();
74 
75  /// Async force session disconnect.
76  ///
77  void disconnectAsync ();
78 
79  /// Replays previously logged data.
80  void replay(const ReplayOptions& options);
81 
82  /// Request address service information
83  ///
84  /// @note The requested information will be provided by ServiceAddressInformationListener::onServiceAddressInformation callback.
85  ///
86  /// @throws OperationException Attempt to send data before connection creation
87  /// @throws std::exception with system dependent message if requesting has been failed
88  void requestAddressServiceInformation ();
89 
90  /// subscribe to market information
91  ///
92  /// @param classId ClassId to subscribe to.
93  ///
94  /// @note The subscribed information will be provided by corresponding callbacks.
95  ///
96  /// @throws OperationException Attempt to send data before connection creation
97  /// @throws std::exception with system dependent message if requesting has been failed
98  void subscribe(ClassId::Enum classId, SubscribeType::Enum subscribeType = SubscribeType::All);
99 
100  /// subscribe to market information with filter
101  void subscribeFiltered(ClassId::Enum classId, UInt32 filterKey, SubscribeType::Enum subscribeType = SubscribeType::All);
102 
103  /// unsubscribe from market information
104  ///
105  /// @param classId ClassId to unsubscribe from.
106  ///
107  /// @throws OperationException Attempt to send data before connection creation
108  /// @throws std::exception with system dependent message if requesting has been failed
109  void unsubscribe(ClassId::Enum classId);
110 
111  /// perform action
112  ///
113  /// @param
114  ///
115  /// @throws OperationException Attempt to send data before connection creation
116  /// @throws std::exception with system dependent message if requesting has been failed
117  UInt32 act(ActionType::Enum actionType, Class* msg, bool dataInResponse = false);
118 
119  /// add filter
120  /// return filter key
121  UInt32 addFilter(UInt32 filterId, const std::string& value);
122 
123  /// Assigns listener for errors occurred while executing handler.
124  /// It's permissible to change the listener multiple times during
125  /// handler's life-time, but only when handler is in disconnected state.
126  /// @throw OperationException if handler not disconnected
127  void registerErrorListener (ErrorListener* listener);
128 
129  /// Assigns listener for warnings occurred while executing handler.
130  /// It's permissible to change the listener multiple times during
131  /// handler's life-time, but only when handler is in disconnected state.
132  /// @throw OperationException if handler not disconnected
133  void registerWarningListener (WarningListener* listener);
134 
135  /// Assigns listener for state change events occurred while executing handler.
136  /// It's permissible to change the listener multiple times during
137  /// handler's life-time, but only when handler is in disconnected state.
138  /// @throw OperationException if handler not disconnected.
139  void registerHandlerStateListener (HandlerStateListener* listener);
140 
141  /// Assigns listener for session events occurred while executing handler.
142  /// It's permissible to change the listener multiple times during
143  /// handler's life-time, but only when handler is in disconnected state.
144  /// @throw OperationException if handler not disconnected.
145  void registerSessionListener (SessionListener* listener);
146 
147  /// Assigns listener for notification abaout address service information.
148  /// It's permissible to change the listener multiple times during
149  /// handler's life-time, but only when handler is in disconnected state.
150  /// @throw OperationException if handler not disconnected.
151  void registerServiceAddressInformationListener (ServiceAddressInformationListener* listener);
152 
153  /// Assigns listener for administrative events.
154  /// It's permissible to change the listener multiple times during
155  /// handler's life-time, but only when handler is in disconnected state.
156  /// @throw OperationException if handler not disconnected.
157  void registerAdminMessageListener (AdminMessageListener* listener);
158 
159  /// Assigns listener for exchange events.
160  /// It's permissible to change the listener multiple times during
161  /// handler's life-time, but only when handler is in disconnected state.
162  /// @throw OperationException if handler not disconnected.
163  void registerClassListener (ClassListener* listener);
164 
165  /// Assigns listener for action result events.
166  /// It's permissible to change the listener multiple times during
167  /// handler's life-time, but only when handler is in disconnected state.
168  /// @throw OperationException if handler not disconnected.
169  void registerActResultListener(ActResultListener* listener);
170 
171  /// Assigns listener for action result events.
172  /// It's permissible to change the listener multiple times during
173  /// handler's life-time, but only when handler is in disconnected state.
174  /// @throw OperationException if handler not disconnected.
175  void registerSubscriptionListener(SubscriptionListener* listener);
176 
177  /// Returns handler state.
178  ///
179  HandlerState::Enum state () const;
180 
181  /// Logs the given user-level message to the handler log.
182  ///
183  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
184 
185  /// Logs the given user-level message to the handler log
186  ///
187  void log (LogLevel::Enum logLevel, const char* logMessage);
188 
189  /// Logs the given user-level message to the handler log.
190  ///
191  void log (LogLevel::Enum logLevel, const std::string& str);
192 
193  /// Returns the license expiration date.
194  ///
195  const std::string& licenseExpirationDate () const;
196 
197  /// Returns Handler's version.
198  ///
199  static const std::string version ();
200 
201 private:
202  Handler (const Handler&); // no implementation
203  Handler& operator = (const Handler&); // no implementation
204 
205 private:
206  struct Impl;
207  Impl* impl_;
208 };
209 }
210 }
211 }
212 }
unsigned short UInt16
Definition: Defines.h:45
Defines ONIXS_CBOECFE_PITCH_API which affect logs replay.
Definition: Replay.h:56
unsigned int UInt32
Definition: Defines.h:46