OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.3
API documentation
EmdiHandlerManager.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 EmdiHandlerSettings& settings)
43  : settings_(settings)
44  {
45  }
46 
48  {
49  BOOST_FOREACH(EmdiHandler* handler, handlers_)
50  {
51  delete handler;
52  }
53 
54  handlers_.clear();
55  }
56 
58  std::vector<EmdiHandler*> 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 
139 
141 {
142  orderBookListener_ = listener;
143 }
144 
146 {
147  tradeListener_ = listener;
148 }
149 
150 void EmdiHandlerManager::start(const IInterfaceDescriptorProvider* provider, const MarketSegments& productNames, FeedEngine& feedEngine)
151 {
152  std::stringstream message;
153  message << "OnixS C++ Eurex EMDI Handler, created by EmdiHandlerManager, version " << EmdiHandler::version () << '.' << std::endl;
154 
155  std::string logFileNamePrefix = impl_->settings_.logFileNamePrefix;
156 
157  EmdiDescriptors descriptors = provider->findEmdiDescriptors(productNames);
158  int i = 1;
159  BOOST_FOREACH( const EmdiDescriptor& descriptor, descriptors)
160  {
161  if(!logFileNamePrefix.empty())
162  impl_->settings_.logFileNamePrefix = logFileNamePrefix + Util::i2str(i);
163  else
164  impl_->settings_.logFileNamePrefix = std::string("Emdi_") + Util::i2str(i);
165 
168  i++;
169 
170  boost::movelib::unique_ptr<EmdiHandler> handler(new EmdiHandler(impl_->settings_));
171 
172  handler->log(LogLevel::Info, message.str());
173 
174  handler->registerErrorListener(errorListener_);
175  handler->registerWarningListener(warningListener_);
176  handler->registerDepthListener(depthListener_);
177  handler->registerTopOfBookImpliedListener(topOfBookImpliedListener_);
178  handler->registerProductStateChangeListener(productStateChangeListener_);
179  handler->registerMassInstrumentStateChangeListener(massInstrumentStateChangeListener_);
180  handler->registerInstrumentStateChangeListener(instrumentStateChangeListener_);
181  handler->registerQuoteRequestListener(quoteRequestListener_);
182  handler->registerCrossRequestListener(crossRequestListener_);
183  handler->registerComplexInstrumentUpdateListener(complexInstrumentUpdateListener_);
184  handler->registerFlexibleInstrumentUpdateListener(flexibleInstrumentUpdateListener_);
185  handler->registerOrderBookListener(orderBookListener_);
186  handler->registerTradeListener(tradeListener_);
187 
188  handler->setMarketSegmentId2Depth(descriptor.marketSegmentId2Depth);
189 
190  handler->setPartitionIdFilters(descriptor.partitionIdFilters);
191  handler->setMarketSegmentIdFilters(descriptor.marketSegmentIdFilters);
192 
193  handler->bindFeedEngine(feedEngine);
194 
195  impl_->handlers_.push_back(handler.release());
196  }
197 
198  impl_->settings_.logFileNamePrefix = logFileNamePrefix;
199 
200  BOOST_FOREACH( EmdiHandler* handler, impl_->handlers_)
201  {
202  handler->start();
203  }
204 }
205 
207 {
208  BOOST_FOREACH( EmdiHandler* handler, impl_->handlers_)
209  {
210  handler->stop();
211  }
212 
213  BOOST_FOREACH( EmdiHandler* handler, impl_->handlers_)
214  {
215  delete handler;
216  }
217 
218  impl_->handlers_.clear();
219 }
220 
221 }}}
222 
void registerInstrumentStateChangeListener(InstrumentStateChangeListener *listener)
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
void registerCrossRequestListener(CrossRequestListener *listener)
void start(const IInterfaceDescriptorProvider *provider, const MarketSegments &productNames, FeedEngine &feedEngine)
static const char * version()
Returns Handler&#39;s version.
InterfaceDescriptor interfaceDescriptor
Sets data interface technical configuration.
void registerDepthListener(DepthListener *listener)
MarketSegmentId2Depth marketSegmentId2Depth
Contains market segment to maximum number of price levels for the product map.
void registerMassInstrumentStateChangeListener(MassInstrumentStateChangeListener *listener)
void registerTradeListener(TradeListener *listener)
void registerWarningListener(WarningListener *listener)
void registerFlexibleInstrumentUpdateListener(FlexibleInstrumentUpdateListener *listener)
void registerQuoteRequestListener(QuoteRequestListener *listener)
void registerErrorListener(ErrorListener *listener)
Definition: Defines.h:30
EMDI handler configuration settings.
virtual ~EmdiHandlerManager()
Finalizes the Handler.
std::string logFileNamePrefix
Template of log file name without extension.
void registerProductStateChangeListener(ProductStateChangeListener *listener)
EmdiDescriptor::Collection EmdiDescriptors
Eurex Enhanced Market Data Interface Handler.
Definition: EmdiHandler.h:56
void registerComplexInstrumentUpdateListener(ComplexInstrumentUpdateListener *listener)
MarketSegmentIdFilters marketSegmentIdFilters
Contains list of market segment ids.
virtual EmdiDescriptors findEmdiDescriptors(const MarketSegments &productNames) const =0
PartitionIdFilters partitionIdFilters
Contains list of interface partition ids.
void registerOrderBookListener(OrderBookListener *listener)
IInterfaceDescriptorProvider::MarketSegments MarketSegments
EmdiHandlerManager(const EmdiHandlerSettings &settings)
void registerTopOfBookImpliedListener(TopOfBookImpliedListener *listener)