OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler  1.12.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 
28 
29 
30 namespace OnixS {
31 namespace CboeCFE {
32 namespace Trading {
33 namespace BOE {
34 
35 ONIXS_CBOE_CFE_BOE_API_DECL(struct, OutgoingMessage);
36 ONIXS_CBOE_CFE_BOE_API_DECL(class, ErrorListener);
37 ONIXS_CBOE_CFE_BOE_API_DECL(class, WarningListener);
38 ONIXS_CBOE_CFE_BOE_API_DECL(class, MessageListener);
39 ONIXS_CBOE_CFE_BOE_API_DECL(class, SessionListener);
40 ONIXS_CBOE_CFE_BOE_API_DECL(class, ReplayListener);
41 ONIXS_CBOE_CFE_BOE_API_DECL(struct, HandlerSettings);
42 ONIXS_CBOE_CFE_BOE_API_DECL(struct, LogonSettings);
43 ONIXS_CBOE_CFE_BOE_API_DECL(class, HandlerStateListener);
44 
45 ///
46 typedef std::pair<Port, Port> PortRange;
47 
48 /// OnixS CBOE CFE Binary Order Entry (BOE) Handler
49 ///
50 class ONIXS_CBOE_CFE_BOE_API Handler
51 {
52 public:
53  /// Performs instance initialization.
54  /// @param settings defines values for various options
55  /// which affect handler behavior like enabling logging
56  /// during execution of the handler.
57  explicit Handler (const HandlerSettings& settings);
58 
59  virtual ~Handler();
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 logonSettings Initial logon message parameters.
68  ///
69  /// @param hostName Hostname to connect to.
70  ///
71  /// @param port Port number to connect to.
72  ///
73  /// @param localNetworkInterface Local network interface.
74  ///
75  /// @param localPortRange Range to choose local port from.
76  ///
77  /// @throw std::exception Cannot set the local network interface.
78  /// @throw std::exception Cannot connect to hostname on port.
79  /// @throw std::exception Cannot configure size of receive buffer for the socket.
80  /// @throw std::exception Cannot configure size of send buffer for the socket.
81  /// @throw OperationException Invalid argument is given.
82  void connect (const LogonSettings& logonSettings,
83  const std::string& hostName,
84  Port port,
85  const std::string& localNetworkInterface = "", const PortRange& localPortRange = PortRange(0,0));
86 
87  /// Force session disconnect.
88  ///
89  /// @note Blocks until the Session Logout procedure is finished.
90  void disconnect ();
91 
92  /// Async force session disconnect.
93  ///
94  void disconnectAsync ();
95 
96  /// \return the local network port number.
97  Port localPort();
98 
99  /// Assigns listener for errors occurred while executing handler.
100  /// It's permissible to change the listener multiple times during
101  /// handler's life-time, but only when handler is in disconnected state.
102  /// @throw OperationException if handler not disconnected
103  void registerErrorListener (ErrorListener* listener);
104 
105  /// Assigns listener for warnings occurred while executing handler.
106  /// It's permissible to change the listener multiple times during
107  /// handler's life-time, but only when handler is in disconnected state.
108  /// @throw OperationException if handler not disconnected
109  void registerWarningListener (WarningListener* listener);
110 
111  /// Assigns listener for state change events occurred while executing handler.
112  /// It's permissible to change the listener multiple times during
113  /// handler's life-time, but only when handler is in disconnected state.
114  /// @throw OperationException if handler not disconnected.
115  void registerHandlerStateListener (HandlerStateListener* listener);
116 
117  /// Assigns listener for session events occurred while executing handler.
118  /// It's permissible to change the listener multiple times during
119  /// handler's life-time, but only when handler is in disconnected state.
120  /// @throw OperationException if handler not disconnected.
121  void registerSessionListener (SessionListener* listener);
122 
123  /// Assigns listener for message events occurred while executing handler.
124  /// It's permissible to change the listener multiple times during
125  /// handler's life-time, but only when handler is in disconnected state.
126  /// @throw OperationException if handler not disconnected.
127  void registerMessageListener(MessageListener* listener);
128 
129  /// Assigns listener for message events occurred while executing handler.
130  /// It's permissible to change the listener multiple times during
131  /// handler's life-time, but only when handler is in disconnected state.
132  /// @throw OperationException if handler not disconnected.
133  void registerReplayListener(ReplayListener* listener);
134 
135  ///// Sends outgoing message
136  /////
137  ///// @throws OperationException Attempt to send data before connection creation
138  ///// @throws std::exception with system dependent message if requesting has been failed
139  UInt32 send(const OutgoingMessage&);
140 
141  ///// Warms outgoing messageup
142  /////
143  ///// @throws OperationException Attempt to send data before connection creation
144  ///// @throws std::exception with system dependent message if requesting has been failed
145  ///// @param warmupFlags Specific flags which can be used to turn on the warmup feature for a specific NIC.
146  void warmup(OutgoingMessage&, int warmupFlags = 0);
147 
148  /// Sets the next sequence number for sending messages
149  void nextSendingSeqNum(SeqNumber value);
150 
151  /// Gets the next sequence number for sending messages
152  SeqNumber nextSendingSeqNum();
153 
154  /// Returns handler state.
155  ///
156  HandlerState::Enum state () const;
157 
158  /// Logs the given user-level message to the handler log.
159  ///
160  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
161 
162  /// Logs the given user-level message to the handler log
163  ///
164  void log (LogLevel::Enum logLevel, const char* logMessage);
165 
166  /// Logs the given user-level message to the handler log.
167  ///
168  void log (LogLevel::Enum logLevel, const std::string& str);
169 
170  /// Returns the license expiration date.
171  ///
172  const std::string& licenseExpirationDate () const;
173 
174  /// Returns Handler's version.
175  ///
176  static const std::string version ();
177 
178 private:
179  Handler (const Handler&); // no implementation
180  Handler& operator = (const Handler&); // no implementation
181 
182 private:
183  struct Impl;
184  Impl* impl_;
185 };
186 }
187 }
188 }
189 }
ONIXS_CBOE_CFE_BOE_API_DECL(struct, OutgoingMessage)
std::pair< Port, Port > PortRange
Definition: Handler.h:46
Incoming (CFE to TPH) message listener.
Base class for outgoing messages.
unsigned short Port
Definition: Defines.h:39