OnixS C++ MTS Repo SDP Handler  1.3.2.8
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/Repo/SDP/ABI.h>
28 
29 
30 namespace OnixS {
31 namespace Mts {
32 namespace Repo {
33 namespace SDP {
34 
35 class Class;
36 
37 /// OnixS MTS Repo/SDP Handler
38 ///
40 {
41 public:
42  /// Performs instance initialization.
43  /// @param settings defines values for various options
44  /// which affect handler behavior like enabling logging
45  /// during execution of the handler.
46  Handler (const HandlerSettings& settings);
47 
48  virtual ~Handler();
49 
50  /// Establishes the connection.
51  ///
52  /// @note Blocks until the logon reply is received.
53  ///
54  /// @note Should be called only when Handler is disconnected.
55  ///
56  /// @param hostName Hostname to connect to.
57  ///
58  /// @param port Port number to connect to.
59  ///
60  /// @param logon Initial logon message parameters.
61  ///
62  /// @param localNetworkInterface Local network interface.
63  ///
64  /// @throw std::exception Cannot set the local network interface.
65  /// @throw std::exception Cannot connect to hostname on port.
66  /// @throw std::exception Cannot configure size of receive buffer for the socket.
67  /// @throw std::exception Cannot configure size of send buffer for the socket.
68  /// @throw OperationException Invalid argument is given.
69  void connect (const ConnectionSettings& connectionSettings, const LogonSettings& logonSettings, const std::string& hostName, UInt16 port, const std::string& localNetworkInterface = "");
70 
71  /// Force session disconnect.
72  ///
73  /// @note Blocks until the Session Logout procedure is finished.
74  void disconnect ();
75 
76  /// Async force session disconnect.
77  ///
78  void disconnectAsync ();
79 
80  /// Request address service information
81  ///
82  /// @note The requested information will be provided by ServiceAddressInformationListener::onServiceAddressInformation callback.
83  ///
84  /// @throws OperationException Attempt to send data before connection creation
85  /// @throws std::exception with system dependent message if requesting has been failed
86  void requestAddressServiceInformation ();
87 
88  /// subscribe to market information
89  ///
90  /// @param classId ClassId to subscribe to.
91  ///
92  /// @note The subscribed information will be provided by corresponding callbacks.
93  ///
94  /// @throws OperationException Attempt to send data before connection creation
95  /// @throws std::exception with system dependent message if requesting has been failed
96  void subscribe(ClassId::Enum classId, SubscribeType::Enum subscribeType = SubscribeType::All);
97 
98  /// subscribe to market information with filter
99  void subscribeFiltered(ClassId::Enum classId, UInt32 filterKey, SubscribeType::Enum subscribeType = SubscribeType::All);
100 
101  /// unsubscribe from market information
102  ///
103  /// @param classId ClassId to unsubscribe from.
104  ///
105  /// @throws OperationException Attempt to send data before connection creation
106  /// @throws std::exception with system dependent message if requesting has been failed
107  void unsubscribe(ClassId::Enum classId);
108 
109 
110  /// perform action
111  ///
112  /// @param
113  ///
114  /// @throws OperationException Attempt to send data before connection creation
115  /// @throws std::exception with system dependent message if requesting has been failed
116  UInt32 act(ActionType::Enum actionType, Class* msg, bool dataInResponse = false);
117 
118  /// add filter
119  /// return filter key
120  UInt32 addFilter(UInt32 filterId, const std::string& value);
121 
122  /// Destroy Filter by Key
123  void destroyFilter(UInt32 filterKey);
124 
125 
126  /// Assigns listener for errors occurred while executing handler.
127  /// It's permissible to change the listener multiple times during
128  /// handler's life-time, but only when handler is in disconnected state.
129  /// @throw OperationException if handler not disconnected
130  void registerErrorListener (ErrorListener* listener);
131 
132  /// Assigns listener for warnings occurred while executing handler.
133  /// It's permissible to change the listener multiple times during
134  /// handler's life-time, but only when handler is in disconnected state.
135  /// @throw OperationException if handler not disconnected
136  void registerWarningListener (WarningListener* listener);
137 
138  /// Assigns listener for state change events occurred while executing handler.
139  /// It's permissible to change the listener multiple times during
140  /// handler's life-time, but only when handler is in disconnected state.
141  /// @throw OperationException if handler not disconnected.
142  void registerHandlerStateListener (HandlerStateListener* listener);
143 
144  /// Assigns listener for session events occurred while executing handler.
145  /// It's permissible to change the listener multiple times during
146  /// handler's life-time, but only when handler is in disconnected state.
147  /// @throw OperationException if handler not disconnected.
148  void registerSessionListener (SessionListener* listener);
149 
150  /// Assigns listener for notification abaout address service information.
151  /// It's permissible to change the listener multiple times during
152  /// handler's life-time, but only when handler is in disconnected state.
153  /// @throw OperationException if handler not disconnected.
154  void registerServiceAddressInformationListener (ServiceAddressInformationListener* listener);
155 
156  /// Assigns listener for administrative events.
157  /// It's permissible to change the listener multiple times during
158  /// handler's life-time, but only when handler is in disconnected state.
159  /// @throw OperationException if handler not disconnected.
160  void registerAdminMessageListener (AdminMessageListener* listener);
161 
162  /// Assigns listener for exchange events.
163  /// It's permissible to change the listener multiple times during
164  /// handler's life-time, but only when handler is in disconnected state.
165  /// @throw OperationException if handler not disconnected.
166  void registerClassListener (ClassListener* listener);
167 
168 
169  /// Assigns listener for action result events.
170  /// It's permissible to change the listener multiple times during
171  /// handler's life-time, but only when handler is in disconnected state.
172  /// @throw OperationException if handler not disconnected.
173  void registerActResultListener(ActResultListener* listener);
174 
175  /// Assigns listener for action result events.
176  /// It's permissible to change the listener multiple times during
177  /// handler's life-time, but only when handler is in disconnected state.
178  /// @throw OperationException if handler not disconnected.
179  void registerSubscriptionListener(SubscriptionListener* listener);
180 
181 
182  /// Returns handler state.
183  ///
184  HandlerState::Enum state () const;
185 
186  /// return outbound queue size
187  ///
188  UInt32 outboundQueueBytes();
189 
190  /// Logs the given user-level message to the handler log.
191  ///
192  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
193 
194  /// Logs the given user-level message to the handler log
195  ///
196  void log (LogLevel::Enum logLevel, const char* logMessage);
197 
198  /// Logs the given user-level message to the handler log.
199  ///
200  void log (LogLevel::Enum logLevel, const std::string& str);
201 
202  /// Returns the license expiration date.
203  ///
204  const std::string& licenseExpirationDate () const;
205 
206  /// Returns Handler's version.
207  ///
208  static const std::string version ();
209 
210 private:
211  Handler (const Handler&); // no implementation
212  Handler& operator = (const Handler&); // no implementation
213 
214 private:
215  struct Impl;
216  Impl* impl_;
217 };
218 }
219 }
220 }
221 }
unsigned short UInt16
Definition: Defines.h:45
unsigned int UInt32
Definition: Defines.h:46
#define ONIXS_MTS_REPO_SDP_API
Definition: ABI.h:49