OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
EmdsHandlerImpl.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
5 *
6 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
7 * and international copyright treaties.
8 *
9 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
10 * Services Agreement (the Agreement) and Customer end user license agreements granting
11 * a non-assignable, non-transferable and non-exclusive license to use the software
12 * for it's own data processing purposes under the terms defined in the Agreement.
13 *
14 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
15 * of this source code or associated reference material to any other location for further reproduction
16 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
17 *
18 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
19 * the terms of the Agreement is a violation of copyright law.
20 */
21 
23 
24 #include "Formatting.h"
25 #include "PacketProcessor.h"
26 #include "ListenerHolder.h"
27 #include "BaseHandlerImp.h"
28 
29 namespace OnixS {
30 namespace Eurex {
31 namespace MarketData {
32 namespace Implementation {
33 
35 
37 {
38  typedef BaseHandlerImp base;
39 
40 public:
41  /// Initialize new instance.
42  explicit EmdsHandlerImpl(const EmdsHandlerSettings & settings);
43 
44  /// Finalize instance.
45  ~EmdsHandlerImpl() override;
46 
47  void bindFeedEngine(FeedEngine& feedEngine);
48 
49  /// Start handler.
50  void start ();
51 
52  /// Starts replaying previously logged data.
53  void start(const ReplayOptions& options);
54 
55  /// Stop handler.
56  void stop() override;
57 
58  /// Returns commons services as shared object.
59  ListenerHolder& listenerHolder() { return *listenerHolder_; }
60 
61  /// Invoke helpers
62  void invokeError (const std::string& description) override;
63  void invokeWarning (const std::string& description) override;
64 
67  void setSecurityIdFilters(const SecurityIdFilters& filters);
69 
70 private:
71  void initLogger(const HandlerSettings &settings);
72  void initListenerHolder();
73 
74 private:
75 
76  void onStarting() override;
77  void onStopping() override;
78 
79  void onStateChanged(State::Enum newState) override;
80 
81  void createExchangeTradeFeeds(
82  FE::MulticastFeedLayout::Enum layout,
83  FE::ConnectionInfo& connectionA,
84  FE::ConnectionInfo& connectionB,
85  const FE::NifsByFeedRole& nifs);
86 
87  void createOpenInterestsFeeds(
88  FE::MulticastFeedLayout::Enum layout,
89  FE::ConnectionInfo& connectionA,
90  FE::ConnectionInfo& connectionB,
91  const FE::NifsByFeedRole& nifs);
92 
93  void createSettlementFeeds(
94  FE::MulticastFeedLayout::Enum layout,
95  FE::ConnectionInfo& connectionA,
96  FE::ConnectionInfo& connectionB,
97  const FE::NifsByFeedRole& nifs);
98 
99  bool checkDescriptor(FE::MulticastFeedLayout::Enum layout, const FeedDescriptor& descriptor) const;
100 
101 private:
102  LoggerPtr logger_;
103  boost::scoped_ptr<ListenerHolder> listenerHolder_;
104 
105  EmdsHandlerSettings settings_;
106 
108  boost::scoped_ptr<EmdsPacketProcessor> settlementFeedPacketProcessor;
109  boost::scoped_ptr<EmdsPacketProcessor> openInterestPacketProcessor;
110  boost::scoped_ptr<EmdsPacketProcessor> otcTradePacketProcessor;
111  boost::scoped_ptr<EmdsPacketProcessor> exchangeTradePacketProcessor;
112 
113  MulticastFeedClusterPtr settlementFeeds_;
114  MulticastFeedClusterPtr openInterestFeeds_;
115  MulticastFeedClusterPtr otcTradeFeeds_;
116  MulticastFeedClusterPtr exchangeTradeFeeds_;
117 
118  void onSettlementPacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
119  void onSettlementPacketGap();
120  void onSettlementSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
121 
122  void onOpenInterestPacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
123  void onOpenInterestPacketGap();
124  void onOpenInterestSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
125 
126  void onOtcTradePacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
127  void onOtcTradePacketGap();
128  void onOtcTradeSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
129 
130  void onExchangeTradePacketData(DataSource& dataSource, const char* data, size_t length, size_t headerSize);
131  void onExchangeTradePacketGap();
132  void onExchangeTradeSenderCompIdChange(unsigned int lastSenderCompId, unsigned int newSenderCompId, SequenceNumber lastSeqNum, SequenceNumber newSeqNum);
133 
134  void onPacketData(const Logging::LogFacility& logFacility, DataSource& dataSource, const char* data, size_t length, size_t headerSize);
135  void processMessage(const Logging::LogFacility& logFacility, const DataSource& dataSource, const CORE::Message& msg, unsigned int templateId);
136 
137  boost::scoped_ptr<FixDecoder> fixDecoder_;
138 
139  typedef Concurrency::Mutex Mutex;
140  typedef Concurrency::Guard<Mutex> Guard;
141 
142  Mutex marketSegmentIdfiltersLock_;
143  MarketSegmentIdFilters marketSegmentIdfilters_;
144 
145  Mutex securityIdFiltersLock_;
146  SecurityIdFilters securityIdFilters_;
147 
148  void onSettlementInactivity();
149  void onSettlementFeedInactivity(HandlerCore::MarketData::FE::NetFeedRole::Enum id);
150  void onOpenInterestInactivity();
151  void onOpenInterestFeedInactivity(HandlerCore::MarketData::FE::NetFeedRole::Enum id);
152  void onOtcTradeInactivity();
153  void onOtcTradeFeedInactivity(HandlerCore::MarketData::FE::NetFeedRole::Enum id);
154  void onExchangeTradeInactivity();
155  void onExchangeTradeFeedInactivity(HandlerCore::MarketData::FE::NetFeedRole::Enum id);
156 };
157 
158 } // namespace Implementation
159 
161 {
163 
164 public:
165 Impl(const EmdsHandlerSettings & settings)
166  : base(settings)
167 {}
168 };
169 
170 }}}
171 
void invokeWarning(const std::string &description) override
unsigned int SequenceNumber
Alias for sequence numbers.
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:287
void setMarketSegmentIdFilters(const MarketSegmentIdFilters &filters)
Impl(const EmdsHandlerSettings &settings)
boost::scoped_ptr< HandlerCore::Common::HandlerLogger > LoggerPtr
EMDI handler configuration settings.
Handler base configuration settings.
Definition: Defines.h:30
FilteringTraits::MarketSegmentIdFilters MarketSegmentIdFilters
Defines params which affect logs replay.
Definition: Replay.h:77
Implementation::EmdsHandlerImpl base
ListenerHolder & listenerHolder()
Returns commons services as shared object.
void setSecurityIdFilters(const SecurityIdFilters &filters)
EmdsHandlerImpl(const EmdsHandlerSettings &settings)
Initialize new instance.
FilteringTraits::SecurityIdFilters SecurityIdFilters
void invokeError(const std::string &description) override
Invoke helpers.