OnixS Eurex ETI Handler C++ library  9.19.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 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 "OnixS/Eurex/Trading/Export.h"
40 
41 #include <string>
42 
43 namespace OnixS {
44 namespace Eurex {
45 namespace Trading {
46 
47 /// Eurex ETI Trading Handler.
48 class ONIXS_EUREX_ETI_EXPORT Handler
49 {
50 public:
51  /// Performs instance initialization.
52  /// \param settings defines values for various options
53  /// which affect handler behavior like enabling logging
54  /// during execution of the handler.
55  Handler (const HandlerSettings& settings);
56 
57  /// Finalizes the Handler.
58  virtual ~Handler();
59 
60  /**
61  * Establishes the connection.
62  *
63  * @note Blocks until the logon reply is received.
64  *
65  * @note Should be called only when Handler is disconnected.
66  *
67  * @param hostName Hostname to connect to.
68  *
69  * @param port Port number to connect to.
70  *
71  * @param logon Initial logon message parameters.
72  *
73  * @param localNetworkInterface Local network interface.
74  *
75  * @throw std::exception Cannot set the local network interface.
76  * @throw std::exception Cannot connect to hostname on port.
77  * @throw std::exception Cannot configure size of receive buffer for the socket.
78  * @throw std::exception Cannot configure size of send buffer for the socket.
79  * @throw OperationException Invalid argument is given.
80  */
81  void connect (const char* hostName, UInt16 port, const Logon& logon, const char* localNetworkInterface = "");
82 
83  /**
84  * Establishes the connection.
85  *
86  * @note Blocks until the logon reply is received.
87  *
88  * @note Should be called only when Handler is disconnected.
89  *
90  * @param primaryHostName Primary hostname to connect to.
91  *
92  * @param primaryPort Primary port number to connect to.
93  *
94  * @param secondaryHostName Secondary hostname to connect to.
95  *
96  * @param secondaryPort Secondary port number to connect to.
97  *
98  * @param logon Initial logon message parameters.
99  *
100  * @param localNetworkInterface Local network interface.
101  *
102  * @throw std::exception Cannot set the local network interface.
103  * @throw std::exception Cannot connect to hostname on port.
104  * @throw std::exception Cannot configure size of receive buffer for the socket.
105  * @throw std::exception Cannot configure size of send buffer for the socket.
106  * @throw OperationException Invalid argument is given.
107  */
108  void connect (const char* primaryHostName, UInt16 primaryPort, const char* secondaryHostName, UInt16 secondaryPort, const Logon& logon, const char* localNetworkInterface = "");
109 
110  /**
111  * Force session disconnect.
112  *
113  * @note Blocks until the Session Logout procedure is finished.
114  */
115  void disconnect ();
116 
117  /**
118  * Async force session disconnect.
119  */
120  void disconnectAsync ();
121 
122  /// Send message
123  ///
124  /// \returns MsgSeqNum
125  ///
126  /// \throws OperationException Attempt to send data before connection creation
127  /// \throws std::exception with system dependent message if sending has been failed
128  UInt32 send (Message&);
129 
130  /// Assigns listener for errors occurred while executing handler.
131  /// It's permissible to change the listener multiple times during
132  /// handler's life-time, but only when handler is in disconnected state.
133  /// \throw OperationException if handler not disconnected
134  void registerErrorListener (ErrorListener* listener);
135 
136  /// Assigns listener for warnings 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 registerWarningListener (WarningListener* listener);
141 
142  /// Assigns listener for state change events 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 registerHandlerStateListener (HandlerStateListener* listener);
147 
148  /// Assigns listener for session 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 registerSessionListener (SessionListener* listener);
153 
154  /// Assigns listener for connection state change 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 registerConnectionStateListener (ConnectionStateListener* listener);
159 
160  /// Assigns listener for administrative events.
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 registerAdminListener (AdminListener* listener);
165 
166  /// Assigns listener for strategy creation 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 registerStrategyCreationListener (StrategyCreationListener* listener);
171 
172  /// Assigns listener for order handling 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 registerOrderHandlingListener (OrderHandlingListener* listener);
177 
178  /// Assigns listener for quote and cross request 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 registerQuoteAndCrossRequestListener (QuoteAndCrossRequestListener* listener);
183 
184  /// Assigns listener for quote handling 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 registerQuoteHandlingListener (QuoteHandlingListener* listener);
189 
190  /// Assigns listener for other 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 registerInfoListener (InfoListener* listener);
195 
196  /// Assigns listener for TES 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 registerTESListener (TESListener* listener);
201 
202  /// Assigns listener for SRQS 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 registerSRQSListener (SRQSListener* listener);
207 
208  /// Returns handler state.
209  HandlerState::Enum state () const;
210 
211  /// Logs the given user-level message to the handler log.
212  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
213 
214  /// Logs the given user-level message to the handler log
215  void log (LogLevel::Enum logLevel, const char* logMessage);
216 
217  /// Logs the given user-level message to the handler log.
218  void log (LogLevel::Enum logLevel, const std::string& str);
219 
220  /// Returns the license expiration date.
221  const std::string& licenseExpirationDate () const;
222 
223  /// Encrypts the given password using the given key.
224  /// \param password Password to encrypt.
225  /// \param pubKeyPath Path to the RSA public key file.
226  /// \return Encrypted and Base64-encoded password.
227  static std::string encryptPassword(const std::string& password, const std::string& pubKeyPath);
228 
229  /// Returns Handler's version.
230  static const std::string& version ();
231 
232 private:
233  Handler (const Handler&); //no implementation
234  Handler& operator = (const Handler&); //no implementation
235 
236 private:
237  struct Impl;
238  Impl* impl_;
239 };
240 }
241 }
242 }
Eurex ETI Trading Handler.
Definition: Handler.h:48
Initial logon message parameters.
Definition: Logon.h:31
Message base class.
Definition: Message.h:33
Provides events representing changes in the Handler&#39;s connection state.
unsigned int UInt32
Definition: Defines.h:46
Enum
Defines the state that the handler is in.
unsigned short UInt16
Definition: Defines.h:45