OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
MdiHandlerManager.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 #include <boost/foreach.hpp>
20 #include <boost/move/unique_ptr.hpp>
21 
22 #include <sstream>
23 
24 #include <util/Converter.h>
25 
26 #include <OnixS/HandlerCore/Compiler.h>
27 
33 
34 
35 namespace OnixS {
36 namespace Eurex {
37 namespace MarketData {
38 
40 {
41  explicit
42  Impl(const MdiHandlerSettings& settings)
43  : settings_(settings)
44  {
45  }
46 
48  {
49  BOOST_FOREACH(MdiHandler* handler, handlers_)
50  {
51  delete handler;
52  }
53 
54  handlers_.clear();
55  }
56 
58  std::vector<MdiHandler*> handlers_;
59 };
60 
62  : impl_(new Impl(settings))
63  , errorListener_(nullptr)
64  , warningListener_(nullptr)
65  , depthListener_(nullptr)
66  , topOfBookImpliedListener_(nullptr)
67  , productStateChangeListener_(nullptr)
68  , massInstrumentStateChangeListener_(nullptr)
69  , instrumentStateChangeListener_(nullptr)
70  , quoteRequestListener_(nullptr)
71  , crossRequestListener_(nullptr)
72  , complexInstrumentUpdateListener_(nullptr)
73  , flexibleInstrumentUpdateListener_(nullptr)
74  , orderBookListener_(nullptr)
75  , tradeListener_(nullptr)
76 {
77 }
78 
80 {
81  delete impl_;
82 }
83 
85 {
86  errorListener_ = listener;
87 }
88 
90 {
91  warningListener_ = listener;
92 }
93 
95 {
96  depthListener_ = listener;
97 }
98 
100 {
101  topOfBookImpliedListener_ = listener;
102 }
103 
105 {
106  productStateChangeListener_ = listener;
107 }
108 
110 {
111  massInstrumentStateChangeListener_ = listener;
112 }
113 
115 {
116  instrumentStateChangeListener_ = listener;
117 }
118 
120 {
121  quoteRequestListener_ = listener;
122 }
123 
125 {
126  crossRequestListener_ = listener;
127 }
128 
130 {
131  complexInstrumentUpdateListener_ = listener;
132 }
133 
135 {
136  flexibleInstrumentUpdateListener_ = listener;
137 }
138 
140 {
141  orderBookListener_ = listener;
142 }
143 
145 {
146  tradeListener_ = listener;
147 }
148 
149 void MdiHandlerManager::start(const IInterfaceDescriptorProvider* provider, const MarketSegments& productNames, FeedEngine& feedEngine)
150 {
151  std::stringstream message;
152  message << "OnixS C++ Eurex MDI Handler, created by MdiHandlerManager, version " << MdiHandler::version () << '.' << std::endl;
153 
154  std::string logFileNamePrefix = impl_->settings_.logFileNamePrefix;
155 
156  MdiDescriptors descriptors = provider->findMdiDescriptors(productNames);
157  int i = 1;
158  BOOST_FOREACH( const MdiDescriptor& descriptor, descriptors)
159  {
160  if(!logFileNamePrefix.empty())
161  impl_->settings_.logFileNamePrefix = logFileNamePrefix + Util::i2str(i);
162  else
163  impl_->settings_.logFileNamePrefix = std::string("Mdi_") + Util::i2str(i);
164 
167  i++;
168 
169  boost::movelib::unique_ptr<MdiHandler> handler(new MdiHandler(impl_->settings_));
170 
171  handler->log(LogLevel::Info, message.str());
172 
173  handler->registerErrorListener(errorListener_);
174  handler->registerWarningListener(warningListener_);
175  handler->registerDepthListener(depthListener_);
176  handler->registerTopOfBookImpliedListener(topOfBookImpliedListener_);
177  handler->registerProductStateChangeListener(productStateChangeListener_);
178  handler->registerMassInstrumentStateChangeListener(massInstrumentStateChangeListener_);
179  handler->registerInstrumentStateChangeListener(instrumentStateChangeListener_);
180  handler->registerQuoteRequestListener(quoteRequestListener_);
181  handler->registerCrossRequestListener(crossRequestListener_);
182  handler->registerComplexInstrumentUpdateListener(complexInstrumentUpdateListener_);
183  handler->registerFlexibleInstrumentUpdateListener(flexibleInstrumentUpdateListener_);
184  handler->registerOrderBookListener(orderBookListener_);
185  handler->registerTradeListener(tradeListener_);
186 
187  handler->setMarketSegmentId2Depth(descriptor.marketSegmentId2Depth);
188 
189  handler->setMarketSegmentIdFilters(descriptor.marketSegmentIdFilters);
190 
191  handler->bindFeedEngine(feedEngine);
192 
193  impl_->handlers_.push_back(handler.release());
194  }
195 
196  impl_->settings_.logFileNamePrefix = logFileNamePrefix;
197 
198  BOOST_FOREACH( MdiHandler* handler, impl_->handlers_)
199  {
200  handler->start();
201  }
202 }
203 
205 {
206  BOOST_FOREACH( MdiHandler* handler, impl_->handlers_)
207  {
208  handler->stop();
209  }
210 
211  BOOST_FOREACH( MdiHandler* handler, impl_->handlers_)
212  {
213  delete handler;
214  }
215 
216  impl_->handlers_.clear();
217 }
218 
219 }}}
220 
MarketSegmentIdFilters marketSegmentIdFilters
Contains list of market segment ids.
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
virtual ~MdiHandlerManager()
Finalizes the Handler.
void registerOrderBookListener(OrderBookListener *listener)
void registerFlexibleInstrumentUpdateListener(FlexibleInstrumentUpdateListener *listener)
void registerProductStateChangeListener(ProductStateChangeListener *listener)
virtual MdiDescriptors findMdiDescriptors(const MarketSegments &productNames) const =0
void registerComplexInstrumentUpdateListener(ComplexInstrumentUpdateListener *listener)
void registerTradeListener(TradeListener *listener)
MDI handler configuration settings.
MdiHandlerManager(const MdiHandlerSettings &settings)
void registerCrossRequestListener(CrossRequestListener *listener)
Eurex Market Data Interface Handler.
Definition: MdiHandler.h:56
static const char * version()
Returns Handler&#39;s version.
Definition: MdiHandler.cpp:257
Definition: Defines.h:30
void registerWarningListener(WarningListener *listener)
std::string logFileNamePrefix
Template of log file name without extension.
void start(const IInterfaceDescriptorProvider *provider, const MarketSegments &productNames, FeedEngine &feedEngine)
MdiDescriptor::Collection MdiDescriptors
void registerInstrumentStateChangeListener(InstrumentStateChangeListener *listener)
void registerQuoteRequestListener(QuoteRequestListener *listener)
MarketSegmentId2Depth marketSegmentId2Depth
Contains market segment to maximum number of price levels for the product map.
void registerMassInstrumentStateChangeListener(MassInstrumentStateChangeListener *listener)
IInterfaceDescriptorProvider::MarketSegments MarketSegments
void registerDepthListener(DepthListener *listener)
void registerTopOfBookImpliedListener(TopOfBookImpliedListener *listener)
void registerErrorListener(ErrorListener *listener)