OnixS Eurex ETI Handler C++ library  9.22.0
API documentation
Handler.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
13  * part of this source code or associated reference material to any other location for further
14  * reproduction or redistribution, and any amendments to this copyright notice, are expressly
15  * 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 #pragma once
22 
28 #include "OnixS/Eurex/Trading/Export.h"
41 
42 #include <string>
43 
44 namespace OnixS { namespace Eurex { namespace Trading {
45 
46 /// Eurex ETI Trading Handler.
47 class ONIXS_EUREX_ETI_EXPORT Handler
48 {
49 public:
50  /// Performs instance initialization.
51  /// \param settings defines values for various options
52  /// which affect handler behavior like enabling logging
53  /// during execution of the handler.
54  Handler(const HandlerSettings& settings);
55 
56  /// Finalizes the Handler.
57  virtual ~Handler();
58 
59  /**
60  * Establishes the connection.
61  *
62  * @note Blocks until the logon reply is received.
63  *
64  * @note Should be called only when Handler is disconnected.
65  *
66  * @param hostName Hostname to connect to.
67  *
68  * @param port Port number to connect to.
69  *
70  * @param logon Initial logon message parameters.
71  *
72  * @param localNetworkInterface Local network interface.
73  *
74  * @throw std::exception Cannot set the local network interface.
75  * @throw std::exception Cannot connect to hostname on port.
76  * @throw std::exception Cannot configure size of receive buffer for the socket.
77  * @throw std::exception Cannot configure size of send buffer for the socket.
78  * @throw OperationException Invalid argument is given.
79  */
80  void connect(const char* hostName, UInt16 port, const Logon& logon, const char* localNetworkInterface = "");
81 
82  /**
83  * Establishes the connection.
84  *
85  * @note Blocks until the logon reply is received.
86  *
87  * @note Should be called only when Handler is disconnected.
88  *
89  * @param primaryHostName Primary hostname to connect to.
90  *
91  * @param primaryPort Primary port number to connect to.
92  *
93  * @param secondaryHostName Secondary hostname to connect to.
94  *
95  * @param secondaryPort Secondary port number to connect to.
96  *
97  * @param logon Initial logon message parameters.
98  *
99  * @param localNetworkInterface Local network interface.
100  *
101  * @throw std::exception Cannot set the local network interface.
102  * @throw std::exception Cannot connect to hostname on port.
103  * @throw std::exception Cannot configure size of receive buffer for the socket.
104  * @throw std::exception Cannot configure size of send buffer for the socket.
105  * @throw OperationException Invalid argument is given.
106  */
107  void connect(
108  const char* primaryHostName,
109  UInt16 primaryPort,
110  const char* secondaryHostName,
111  UInt16 secondaryPort,
112  const Logon& logon,
113  const char* localNetworkInterface = ""
114  );
115 
116  /**
117  * Force session disconnect.
118  *
119  * @note Blocks until the Session Logout procedure is finished.
120  */
121  void disconnect();
122 
123  /**
124  * Async force session disconnect.
125  */
126  void disconnectAsync();
127 
128  /// Send message
129  ///
130  /// \returns MsgSeqNum
131  ///
132  /// \throws OperationException Attempt to send data before connection creation
133  /// \throws std::exception with system dependent message if sending has been failed
134  UInt32 send(Message&);
135 
136  /**
137  * Checks the throttling of a session that must be called before each send function call.
138  *
139  * If the count of messages per time unit exceeds the throttling limit,
140  * the function returns the delay (in milliseconds) until the sending becomes possible.
141  * Otherwise, it returns 0.
142  *
143  * @note This call is thread-safe.
144  */
145  size_t tryThrottle();
146 
147  /// Assigns listener for errors occurred while executing handler.
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 registerErrorListener(ErrorListener* listener);
152 
153  /// Assigns listener for warnings occurred while executing handler.
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 registerWarningListener(WarningListener* listener);
158 
159  /// Assigns listener for state change events occurred while executing handler.
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 registerHandlerStateListener(HandlerStateListener* listener);
164 
165  /// Assigns listener for session events occurred while executing handler.
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 registerSessionListener(SessionListener* listener);
170 
171  /// Assigns listener for connection state change events occurred while executing handler.
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 registerConnectionStateListener(ConnectionStateListener* listener);
176 
177  /// Assigns listener for administrative events.
178  /// It's permissible to change the listener multiple times during
179  /// handler's life-time, but only when handler is in disconnected state.
180  /// \throw OperationException if handler not disconnected.
181  void registerAdminListener(AdminListener* listener);
182 
183  /// Assigns listener for strategy creation events.
184  /// It's permissible to change the listener multiple times during
185  /// handler's life-time, but only when handler is in disconnected state.
186  /// \throw OperationException if handler not disconnected.
187  void registerStrategyCreationListener(StrategyCreationListener* listener);
188 
189  /// Assigns listener for order handling events.
190  /// It's permissible to change the listener multiple times during
191  /// handler's life-time, but only when handler is in disconnected state.
192  /// \throw OperationException if handler not disconnected.
193  void registerOrderHandlingListener(OrderHandlingListener* listener);
194 
195  /// Assigns listener for quote and cross request events.
196  /// It's permissible to change the listener multiple times during
197  /// handler's life-time, but only when handler is in disconnected state.
198  /// \throw OperationException if handler not disconnected.
199  void registerQuoteAndCrossRequestListener(QuoteAndCrossRequestListener* listener);
200 
201  /// Assigns listener for quote handling events.
202  /// It's permissible to change the listener multiple times during
203  /// handler's life-time, but only when handler is in disconnected state.
204  /// \throw OperationException if handler not disconnected.
205  void registerQuoteHandlingListener(QuoteHandlingListener* listener);
206 
207  /// Assigns listener for other events.
208  /// It's permissible to change the listener multiple times during
209  /// handler's life-time, but only when handler is in disconnected state.
210  /// \throw OperationException if handler not disconnected.
211  void registerInfoListener(InfoListener* listener);
212 
213  /// Assigns listener for TES events.
214  /// It's permissible to change the listener multiple times during
215  /// handler's life-time, but only when handler is in disconnected state.
216  /// \throw OperationException if handler not disconnected.
217  void registerTESListener(TESListener* listener);
218 
219  /// Assigns listener for SRQS events.
220  /// It's permissible to change the listener multiple times during
221  /// handler's life-time, but only when handler is in disconnected state.
222  /// \throw OperationException if handler not disconnected.
223  void registerSRQSListener(SRQSListener* listener);
224 
225  /// Returns handler state.
226  HandlerState::Enum state() const;
227 
228  /// Logs the given user-level message to the handler log.
229  void log(LogLevel::Enum logLevel, const char* logMessage, size_t length);
230 
231  /// Logs the given user-level message to the handler log
232  void log(LogLevel::Enum logLevel, const char* logMessage);
233 
234  /// Logs the given user-level message to the handler log.
235  void log(LogLevel::Enum logLevel, const std::string& str);
236 
237  /// Returns the license expiration date.
238  ///
239  /// Date format is YYYYMMDD.
240  const std::string& licenseExpirationDate() const;
241 
242  /// Encrypts the given password using the given key.
243  /// \param password Password to encrypt.
244  /// \param pubKeyPath Path to the RSA public key file.
245  /// \returns Encrypted and Base64-encoded password.
246  static std::string encryptPassword(const std::string& password, const std::string& pubKeyPath);
247 
248  /// Returns Handler's version.
249  static const std::string& version();
250 
251 private:
252  Handler(const Handler&); // no implementation
253  Handler& operator=(const Handler&); // no implementation
254 
255 private:
256  struct Impl;
257  Impl* impl_;
258 };
259 }}}
Eurex ETI Trading Handler.
Definition: Handler.h:47
Initial logon message parameters.
Definition: Logon.h:30
Message base class.
Definition: Message.h:32
Provides events representing changes in the Handler&#39;s connection state.
unsigned int UInt32
Definition: Defines.h:45
Enum
Defines the state that the handler is in.
unsigned short UInt16
Definition: Defines.h:44