OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
MdiHandler.cpp
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 #include <OnixS/HandlerCore/ErrorBuilder.h>
21 
23 
24 #include "Version.h"
25 #include "MdiHandlerImpl.h"
26 
27 
28 namespace OnixS {
29 namespace Eurex {
30 namespace MarketData {
31 
32 
33 using namespace HandlerCore::MarketData;
34 using namespace HandlerCore::Common;
35 
36 
38  : impl_(nullptr)
39 {
40  try
41  {
42  impl_ = new Impl(settings);
43  }
44  catch (const std::exception& ex)
45  {
46  ErrorBuilder errorBuilder;
47  errorBuilder << "Unable to create MDI Handler: " << ex.what();
48  errorBuilder.toError();
49  }
50  catch (...)
51  {
52  throw OperationException(BOOST_CURRENT_FUNCTION, "Unable to create MDI handler");
53  }
54 }
55 
57 {
58  if (impl_ != nullptr)
59  delete impl_;
60 }
61 
63 {
65  impl_->listenerHolder().set(listener);
66  else
67  throw OperationException(BOOST_CURRENT_FUNCTION,
68  "Unable to change listener while handler connected");
69 }
70 
72 {
74  impl_->listenerHolder().set(listener);
75  else
76  throw OperationException(BOOST_CURRENT_FUNCTION,
77  "Unable to change listener while handler connected");
78 }
79 
81 {
83  impl_->listenerHolder().set(listener);
84  else
85  throw OperationException(BOOST_CURRENT_FUNCTION,
86  "Unable to change listener while handler connected");
87 }
88 
90 {
92  impl_->listenerHolder().set(listener);
93  else
94  throw OperationException(BOOST_CURRENT_FUNCTION,
95  "Unable to change listener while handler connected");
96 }
97 
99 {
100  if (HandlerState::Stopped == state())
101  impl_->listenerHolder().set(listener);
102  else
103  throw OperationException(BOOST_CURRENT_FUNCTION,
104  "Unable to change listener while handler connected");
105 }
106 
108 {
109  if (HandlerState::Stopped == state())
110  impl_->listenerHolder().set(listener);
111  else
112  throw OperationException(BOOST_CURRENT_FUNCTION,
113  "Unable to change listener while handler connected");
114 }
115 
117 {
118  if (HandlerState::Stopped == state())
119  impl_->listenerHolder().set(listener);
120  else
121  throw OperationException(BOOST_CURRENT_FUNCTION,
122  "Unable to change listener while handler connected");
123 }
124 
126 {
127  if (HandlerState::Stopped == state())
128  impl_->listenerHolder().set(listener);
129  else
130  throw OperationException(BOOST_CURRENT_FUNCTION,
131  "Unable to change listener while handler connected");
132 }
133 
135 {
136  if (HandlerState::Stopped == state())
137  impl_->listenerHolder().set(listener);
138  else
139  throw OperationException(BOOST_CURRENT_FUNCTION,
140  "Unable to change listener while handler connected");
141 }
142 
144 {
145  if (HandlerState::Stopped == state())
146  impl_->listenerHolder().set(listener);
147  else
148  throw OperationException(BOOST_CURRENT_FUNCTION,
149  "Unable to change listener while handler connected");
150 }
151 
153 {
154  if (HandlerState::Stopped == state())
155  impl_->listenerHolder().set(listener);
156  else
157  throw OperationException(BOOST_CURRENT_FUNCTION,
158  "Unable to change listener while handler connected");
159 }
160 
162 {
163  if (HandlerState::Stopped == state())
164  impl_->listenerHolder().set(listener);
165  else
166  throw OperationException(BOOST_CURRENT_FUNCTION,
167  "Unable to change listener while handler connected");
168 }
169 
171 {
172  if (HandlerState::Stopped == state())
173  impl_->listenerHolder().set(listener);
174  else
175  throw OperationException(BOOST_CURRENT_FUNCTION,
176  "Unable to change listener while handler connected");
177 }
178 
179 
181 {
182  if (HandlerState::Stopped == state())
183  impl_->listenerHolder().set(listener);
184  else
185  throw OperationException(BOOST_CURRENT_FUNCTION,
186  "Unable to change listener while handler connected");
187 }
188 
190 {
191  if (HandlerState::Stopped == state())
192  impl_->listenerHolder().set(listener);
193  else
194  throw OperationException(BOOST_CURRENT_FUNCTION,
195  "Unable to change listener while handler connected");
196 }
197 
199 {
200  if (HandlerState::Stopped == state())
201  impl_->bindFeedEngine(feedEngine);
202  else
203  throw OperationException(BOOST_CURRENT_FUNCTION,
204  "Unable to change listener while handler connected");
205 }
206 
208 {
209  if (HandlerState::Stopped != state())
210  throw OperationException(BOOST_CURRENT_FUNCTION, "Handler already started");
211 
212  impl_->start();
213 }
214 
215 void MdiHandler::start(const ReplayOptions& options)
216 {
217  if (HandlerState::Stopped != state())
218  throw OperationException(BOOST_CURRENT_FUNCTION, "Handler already started");
219 
220  impl_->start(options);
221 }
222 
224 {
225  impl_->stop();
226 }
227 
228 /*
229  Logging
230 */
231 
232 void
233 MdiHandler::log(OnixS::Eurex::MarketData::LogLevel::Enum logLevel, const char* logMessage, size_t length)
234 {
235  impl_->commonLog(int(logLevel), logMessage, length);
236 }
237 
238 void MdiHandler::log(OnixS::Eurex::MarketData::LogLevel::Enum logLevel, const char* logMessage)
239 {
240  impl_->commonLog(int(logLevel), logMessage, strlen(logMessage));
241 }
242 
243 void MdiHandler::log(OnixS::Eurex::MarketData::LogLevel::Enum logLevel, const std::string& str)
244 {
245  impl_->commonLog(int(logLevel), str.c_str(), str.length());
246 }
247 
248 /*
249  Information requests
250 */
251 
253 {
254  return impl_->licenseExpirationDate().c_str();
255 }
256 
257 const char* MdiHandler::version()
258 {
260 }
261 
263 {
264  return HandlerState::Enum(impl_->getState());
265 }
266 
268 {
269  if (HandlerState::Stopped == state())
270  impl_->setMarketSegmentId2Depth(map);
271  else
272  throw OperationException(BOOST_CURRENT_FUNCTION,
273  "Unable to change MarketSegmentId2Depth map while handler connected");
274 }
275 
277 {
278  if (HandlerState::Stopped == state())
279  impl_->setMarketSegmentIdFilters(filters);
280  else
281  throw OperationException(BOOST_CURRENT_FUNCTION,
282  "Unable to change MarketSegmentIdFilters while handler connected");
283 }
284 
286 {
287  if (HandlerState::Stopped == state())
289  else
290  throw OperationException(BOOST_CURRENT_FUNCTION,
291  "Unable to change MarketSegmentIdFilters while handler connected");
292 }
293 
295 {
296  if (HandlerState::Stopped == state())
297  impl_->setSecurityIdFilters(filters);
298  else
299  throw OperationException(BOOST_CURRENT_FUNCTION,
300  "Unable to change SecurityIdFilters while handler connected");
301 }
302 
304 {
305  if (HandlerState::Stopped == state())
307  else
308  throw OperationException(BOOST_CURRENT_FUNCTION,
309  "Unable to change SecurityIdFilters while handler connected");
310 }
311 
312 }}}
HandlerState::Enum state() const
Returns handler state.
Definition: MdiHandler.cpp:262
void registerCachedDepthIncrementalListener(CachedDepthIncrementalListener *listener)
Definition: MdiHandler.cpp:98
MdiHandler(const MdiHandlerSettings &settings)
Definition: MdiHandler.cpp:37
void registerOrderBookListener(OrderBookListener *listener)
Definition: MdiHandler.cpp:180
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
void removeAllSecurityIdFilters()
Remove all filters.
Definition: MdiHandler.cpp:303
MarketDepthTraits::MarketSegmentId2Depth MarketSegmentId2Depth
void registerFlexibleInstrumentUpdateListener(FlexibleInstrumentUpdateListener *listener)
Definition: MdiHandler.cpp:170
MDI handler configuration settings.
void setMarketSegmentId2Depth(const MarketSegmentId2Depth &map)
Definition: MdiHandler.cpp:267
void setMarketSegmentId2Depth(const MarketSegmentId2Depth &map)
ListenerHolder & listenerHolder()
Returns commons services as shared object.
void registerCrossRequestListener(CrossRequestListener *listener)
Definition: MdiHandler.cpp:152
const char * licenseExpirationDate() const
Returns the license expiration date.
Definition: MdiHandler.cpp:252
void registerTopOfBookImpliedListener(TopOfBookImpliedListener *listener)
Definition: MdiHandler.cpp:107
void log(LogLevel::Enum logLevel, const char *logMessage, size_t length)
Logs the given user-level message to the handler log.
Definition: MdiHandler.cpp:233
void commonLog(int logLevel, const char *msg, size_t length)
User&#39;s common log.
void registerComplexInstrumentUpdateListener(ComplexInstrumentUpdateListener *listener)
Definition: MdiHandler.cpp:161
static const char * version()
Returns Handler&#39;s version.
Definition: MdiHandler.cpp:257
void registerInstrumentStateChangeListener(InstrumentStateChangeListener *listener)
Definition: MdiHandler.cpp:134
Definition: Defines.h:30
void setMarketSegmentIdFilters(const MarketSegmentIdFilters &filters)
FilteringTraits::MarketSegmentIdFilters MarketSegmentIdFilters
Defines params which affect logs replay.
Definition: Replay.h:77
void setSecurityIdFilters(const SecurityIdFilters &filters)
virtual ~MdiHandler()
Finalizes the Handler.
Definition: MdiHandler.cpp:56
void setSecurityIdFilters(const SecurityIdFilters &filters)
Definition: MdiHandler.cpp:294
void registerProductStateChangeListener(ProductStateChangeListener *listener)
Definition: MdiHandler.cpp:116
void setMarketSegmentIdFilters(const MarketSegmentIdFilters &filters)
Definition: MdiHandler.cpp:276
void registerDepthListener(DepthListener *listener)
Definition: MdiHandler.cpp:89
void registerHandlerStateListener(HandlerStateListener *listener)
Definition: MdiHandler.cpp:80
void set(ErrorListener *listener) ONIXS_NOEXCEPT
void registerErrorListener(ErrorListener *listener)
Definition: MdiHandler.cpp:62
void bindFeedEngine(FeedEngine &feedEngine)
Definition: MdiHandler.cpp:198
FilteringTraits::SecurityIdFilters SecurityIdFilters
Enum
Defines the state that the handler is in.
void registerMassInstrumentStateChangeListener(MassInstrumentStateChangeListener *listener)
Definition: MdiHandler.cpp:125
void registerTradeListener(TradeListener *listener)
Definition: MdiHandler.cpp:189
void registerWarningListener(WarningListener *listener)
Definition: MdiHandler.cpp:71
void registerQuoteRequestListener(QuoteRequestListener *listener)
Definition: MdiHandler.cpp:143
void removeAllMarketSegmentIdFilters()
Remove all filters.
Definition: MdiHandler.cpp:285