OnixS Eurex ETI Handler C++ library  9.20.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  /// Assigns listener for errors occurred while executing handler.
137  /// It's permissible to change the listener multiple times during
138  /// handler's life-time, but only when handler is in disconnected state.
139  /// \throw OperationException if handler not disconnected
140  void registerErrorListener(ErrorListener* listener);
141 
142  /// Assigns listener for warnings occurred while executing handler.
143  /// It's permissible to change the listener multiple times during
144  /// handler's life-time, but only when handler is in disconnected state.
145  /// \throw OperationException if handler not disconnected
146  void registerWarningListener(WarningListener* listener);
147 
148  /// Assigns listener for state change events occurred while executing handler.
149  /// It's permissible to change the listener multiple times during
150  /// handler's life-time, but only when handler is in disconnected state.
151  /// \throw OperationException if handler not disconnected.
152  void registerHandlerStateListener(HandlerStateListener* listener);
153 
154  /// Assigns listener for session events occurred while executing handler.
155  /// It's permissible to change the listener multiple times during
156  /// handler's life-time, but only when handler is in disconnected state.
157  /// \throw OperationException if handler not disconnected.
158  void registerSessionListener(SessionListener* listener);
159 
160  /// Assigns listener for connection state change events occurred while executing handler.
161  /// It's permissible to change the listener multiple times during
162  /// handler's life-time, but only when handler is in disconnected state.
163  /// \throw OperationException if handler not disconnected.
164  void registerConnectionStateListener(ConnectionStateListener* listener);
165 
166  /// Assigns listener for administrative events.
167  /// It's permissible to change the listener multiple times during
168  /// handler's life-time, but only when handler is in disconnected state.
169  /// \throw OperationException if handler not disconnected.
170  void registerAdminListener(AdminListener* listener);
171 
172  /// Assigns listener for strategy creation events.
173  /// It's permissible to change the listener multiple times during
174  /// handler's life-time, but only when handler is in disconnected state.
175  /// \throw OperationException if handler not disconnected.
176  void registerStrategyCreationListener(StrategyCreationListener* listener);
177 
178  /// Assigns listener for order handling events.
179  /// It's permissible to change the listener multiple times during
180  /// handler's life-time, but only when handler is in disconnected state.
181  /// \throw OperationException if handler not disconnected.
182  void registerOrderHandlingListener(OrderHandlingListener* listener);
183 
184  /// Assigns listener for quote and cross request events.
185  /// It's permissible to change the listener multiple times during
186  /// handler's life-time, but only when handler is in disconnected state.
187  /// \throw OperationException if handler not disconnected.
188  void registerQuoteAndCrossRequestListener(QuoteAndCrossRequestListener* listener);
189 
190  /// Assigns listener for quote handling events.
191  /// It's permissible to change the listener multiple times during
192  /// handler's life-time, but only when handler is in disconnected state.
193  /// \throw OperationException if handler not disconnected.
194  void registerQuoteHandlingListener(QuoteHandlingListener* listener);
195 
196  /// Assigns listener for other events.
197  /// It's permissible to change the listener multiple times during
198  /// handler's life-time, but only when handler is in disconnected state.
199  /// \throw OperationException if handler not disconnected.
200  void registerInfoListener(InfoListener* listener);
201 
202  /// Assigns listener for TES events.
203  /// It's permissible to change the listener multiple times during
204  /// handler's life-time, but only when handler is in disconnected state.
205  /// \throw OperationException if handler not disconnected.
206  void registerTESListener(TESListener* listener);
207 
208  /// Assigns listener for SRQS events.
209  /// It's permissible to change the listener multiple times during
210  /// handler's life-time, but only when handler is in disconnected state.
211  /// \throw OperationException if handler not disconnected.
212  void registerSRQSListener(SRQSListener* listener);
213 
214  /// Returns handler state.
215  HandlerState::Enum state() const;
216 
217  /// Logs the given user-level message to the handler log.
218  void log(LogLevel::Enum logLevel, const char* logMessage, size_t length);
219 
220  /// Logs the given user-level message to the handler log
221  void log(LogLevel::Enum logLevel, const char* logMessage);
222 
223  /// Logs the given user-level message to the handler log.
224  void log(LogLevel::Enum logLevel, const std::string& str);
225 
226  /// Returns the license expiration date.
227  const std::string& licenseExpirationDate() const;
228 
229  /// Encrypts the given password using the given key.
230  /// \param password Password to encrypt.
231  /// \param pubKeyPath Path to the RSA public key file.
232  /// \return Encrypted and Base64-encoded password.
233  static std::string encryptPassword(const std::string& password, const std::string& pubKeyPath);
234 
235  /// Returns Handler's version.
236  static const std::string& version();
237 
238 private:
239  Handler(const Handler&); // no implementation
240  Handler& operator=(const Handler&); // no implementation
241 
242 private:
243  struct Impl;
244  Impl* impl_;
245 };
246 }}} // namespace OnixS::Eurex::Trading
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