OnixS C++ SGX Titan OUCH Trading Handler  1.2.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 #pragma once
20 
21 #include <string>
22 
27 
28 
30 
31 ONIXS_SGXTITAN_OUCH_API_DECL(class, ErrorListener);
32 ONIXS_SGXTITAN_OUCH_API_DECL(class, WarningListener);
33 ONIXS_SGXTITAN_OUCH_API_DECL(class, MessageListener);
34 ONIXS_SGXTITAN_OUCH_API_DECL(class, SessionListener);
35 ONIXS_SGXTITAN_OUCH_API_DECL(struct, HandlerSettings);
36 ONIXS_SGXTITAN_OUCH_API_DECL(struct, LogonSettings);
37 ONIXS_SGXTITAN_OUCH_API_DECL(class, HandlerStateListener);
38 ONIXS_SGXTITAN_OUCH_API_DECL(class, OutgoingMessage);
39 
40 
41 /// OnixS Sgx Titan OUCH Trading Handler
42 class ONIXS_SGXTITAN_OUCH_API Handler
43 {
44 public:
45  /// Performs instance initialization.
46  /// @param settings defines values for various options
47  /// which affect handler behavior like enabling logging
48  /// during execution of the handler.
49  explicit Handler (const HandlerSettings& settings);
50 
51  virtual ~Handler();
52 
53  /// Establishes the connection.
54  ///
55  /// @note Blocks until the logon reply is received.
56  ///
57  /// @note Should be called only when Handler is disconnected.
58  ///
59  /// @param logonSettings Initial logon message parameters.
60  ///
61  /// @param hostName Hostname to connect to.
62  ///
63  /// @param port Port number to connect to.
64  ///
65  /// @param localNetworkInterface Local network interface.
66  ///
67  /// @throw std::exception Cannot set the local network interface.
68  /// @throw std::exception Cannot connect to hostname on port.
69  /// @throw std::exception Cannot configure size of receive buffer for the socket.
70  /// @throw std::exception Cannot configure size of send buffer for the socket.
71  /// @throw OperationException Invalid argument is given.
72  void connect (const LogonSettings& logonSettings,
73  const std::string& hostName,
74  UInt16 port,
75  const std::string& localNetworkInterface = "");
76 
77  /// Force session disconnect.
78  ///
79  /// @note Blocks until the Session Logout procedure is finished.
80  void disconnect ();
81 
82  /// Async force session disconnect.
83  ///
84  void disconnectAsync ();
85 
86  /// Assigns listener for errors occurred while executing handler.
87  /// It's permissible to change the listener multiple times during
88  /// handler's life-time, but only when handler is in disconnected state.
89  /// @throw OperationException if handler not disconnected
90  void registerErrorListener (ErrorListener* listener);
91 
92  /// Assigns listener for warnings occurred while executing handler.
93  /// It's permissible to change the listener multiple times during
94  /// handler's life-time, but only when handler is in disconnected state.
95  /// @throw OperationException if handler not disconnected
96  void registerWarningListener (WarningListener* listener);
97 
98  /// Assigns listener for state change events occurred while executing handler.
99  /// It's permissible to change the listener multiple times during
100  /// handler's life-time, but only when handler is in disconnected state.
101  /// @throw OperationException if handler not disconnected.
102  void registerHandlerStateListener (HandlerStateListener* listener);
103 
104  /// Assigns listener for session events occurred while executing handler.
105  /// It's permissible to change the listener multiple times during
106  /// handler's life-time, but only when handler is in disconnected state.
107  /// @throw OperationException if handler not disconnected.
108  void registerSessionListener (SessionListener* listener);
109 
110  /// Assigns listener for message events occurred while executing handler.
111  /// It's permissible to change the listener multiple times during
112  /// handler's life-time, but only when handler is in disconnected state.
113  /// @throw OperationException if handler not disconnected.
114  void registerMessageListener(MessageListener* listener);
115 
116  ///// Sends outgoing message
117  /////
118  ///// @throws OperationException Attempt to send data before connection creation
119  ///// @throws std::exception with system dependent message if requesting has been failed
120  void send(const OutgoingMessage&);
121 
122 
123  /// The next Sequenced Message number to be sent by the exchange
124  UInt64 nextExpectedSequenceNumber() const;
125 
126  /// session id
127  std::string sessionId() const;
128 
129  /// Returns handler state.
130  ///
131  HandlerState::Enum state () const;
132 
133  /// Logs the given user-level message to the handler log.
134  ///
135  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
136 
137  /// Logs the given user-level message to the handler log
138  ///
139  void log (LogLevel::Enum logLevel, const char* logMessage);
140 
141  /// Logs the given user-level message to the handler log.
142  ///
143  void log (LogLevel::Enum logLevel, const std::string& str);
144 
145  /// Returns the license expiration date.
146  ///
147  const std::string& licenseExpirationDate () const;
148 
149  /// Returns Handler's version.
150  ///
151  static const std::string version ();
152 
153 private:
154  Handler (const Handler&); // no implementation
155  Handler& operator = (const Handler&); // no implementation
156 
157 private:
158  struct Impl;
159  Impl* impl_;
160 };
161 
const char * version()
Definition: Version.cpp:27
Incoming (CFE to TPH) message listener.
Enum
Defines the state that the handler is in.
#define ONIXS_SGXTITAN_OUCH_NAMESPACE_END
Definition: Bootstrap.h:31
#define ONIXS_SGXTITAN_OUCH_NAMESPACE_BEGIN
Definition: Bootstrap.h:27
#define ONIXS_SGXTITAN_OUCH_API_DECL(typeKind, typeName)
Definition: ABI.h:30
OnixS Sgx Titan OUCH Trading Handler.
Definition: Handler.h:42