OnixS C++ Tullett Prebon SURF Handler  1.6.1
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 
24 #include <OnixS/SURF/MarketData/Export.h>
30 
31 #include <string>
32 
33 namespace OnixS { namespace SURF { namespace MarketData {
34 
35 /// SURF Market Data Handler.
36 class ONIXS_TP_SURF_EXPORT Handler
37 {
38 public:
39  /// Performs instance initialization.
40  /// \param settings defines values for various options
41  /// which affect handler behavior like enabling logging
42  /// during execution of the handler.
43  Handler(const HandlerSettings& settings);
44 
45  /// Finalizes the Handler.
46  virtual ~Handler();
47 
48  /// Assigns listener for errors occurred while executing handler.
49  /// It's permissible to change the listener multiple times during
50  /// handler's life-time, but only when handler is in disconnected state.
51  /// \throw OperationException if handler not disconnected
52  void registerErrorListener(ErrorListener* listener);
53 
54  /// Assigns listener for warnings occurred while executing handler.
55  /// It's permissible to change the listener multiple times during
56  /// handler's life-time, but only when handler is in disconnected state.
57  /// \throw OperationException if handler not disconnected
58  void registerWarningListener(WarningListener* listener);
59 
60  /// Assigns listener for state change events occurred while executing handler.
61  /// It's permissible to change the listener multiple times during
62  /// handler's life-time, but only when handler is in disconnected state.
63  /// \throw OperationException if handler not disconnected.
64  void registerHandlerStateListener(HandlerStateListener* listener);
65 
66  /// Assigns listener for records received while executing handler.
67  /// It's permissible to change the listener multiple times during
68  /// handler's life-time, but only when handler is in disconnected state.
69  /// \throw OperationException if handler not disconnected.
70  void registerRecordListener(RecordListener* listener);
71 
72  /// Connects the Handler to the given host and port.
73  ///
74  /// \throw std::exception in case of unable to establish TCP connection.
75  void connect(const std::string& host, int port);
76 
77  /// Disconnects the Handler.
78  void disconnect();
79 
80  /// Subscribes to the records with given field ID.
81  ///
82  /// \param fieldId - identifier of field.
83  /// \throw ArgumentRangeException if fieldId is not in valid range.
84  void subscribe(FieldId fieldId);
85 
86  /// Unsubscribes for the records with given field ID.
87  ///
88  /// \param fieldId - identifier of field.
89  /// \throw ArgumentRangeException if fieldId is not in valid range.
90  void unsubscribe(FieldId fieldId);
91 
92  /// Returns handler state.
93  HandlerState::Enum state() const;
94 
95  /// Logs the given user-level message to the handler log.
96  void log(LogLevel::Enum logLevel, const char* logMessage, size_t length);
97 
98  /// Logs the given user-level message to the handler log
99  void log(LogLevel::Enum logLevel, const char* logMessage);
100 
101  /// Logs the given user-level message to the handler log.
102  void log(LogLevel::Enum logLevel, const std::string& str);
103 
104  /// Returns the license expiration date.
105  const char* licenseExpirationDate() const;
106 
107  /// Returns Handler's version.
108  static const char* version();
109 
110 private:
111  Handler(const Handler&); // no implementation
112  Handler& operator=(const Handler&); // no implementation
113 
114 private:
115  struct Impl;
116  Impl* impl_;
117 };
118 
119 }}} // namespace OnixS::SURF::MarketData
Definition: Decimal.h:28
Enum
Defines the state that the handler is in.
unsigned int FieldId
Alias for field ID.
Definition: Defines.h:49
SURF Market Data Handler.
Definition: Handler.h:36