OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.3
API documentation
EmdiDataRepository.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 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 #pragma once
20 
21 #include <set>
22 #include <map>
23 
26 
27 #include "DataRepository.hpp"
28 #include "ListenerHolder.h"
29 #include "InternalDefines.h"
30 
31 
32 namespace TestHelpers { struct EmdiDataRepositoryAccessor; }
33 
34 
35 namespace OnixS {
36 namespace Eurex {
37 namespace MarketData {
38 namespace Implementation {
39 
40 
42 
44 
46 
47 class EmdiDataRepository : public DataRepository<EmdiDataRepositoryConfig>
48 {
50 
51 public:
52  explicit EmdiDataRepository(const EmdiDataRepositoryConfig &config);
53  virtual ~EmdiDataRepository();
54 
55  void onIncrementalMessage(const DataSource& dataSource, const CORE::Message& msg, TemplateId templateId);
56  void onIncrementalPacketGap();
57  void onIncrementalSenderCompIdChange();
58  void noDataOnIncrementalFeeds();
59 
60  void onSnapshotMessage(const DataSource& dataSource, const CORE::Message& msg, bool* skipRestOfPacket);
61  void onSnapshotSenderCompIdChange();
62 
63  void setMarketSegmentId2Depth(const MarketSegmentId2Depth& map);
64 
65  void setMarketSegmentIdFilters(const MarketSegmentIdFilters& filters);
66  void clearMarketSegmentIdFilters();
67 
68  void setSecurityIdFilters(const SecurityIdFilters& filters);
69  void removeAllSecurityIdFilters();
70 
71  void preBuildProductDataRepositories();
72 
73  bool hasCashedIncrementals() const;
74 
75 
76 private:
77  void resetRecoveryProcess();
78  EmdiProductDataRepository* getOrCreateProductDataRepository(MarketSegmentId marketSegmentId, bool create);
79  void snapshotRecoveryCycleMethodOne(const DataSource&, const CORE::Message&);
80  void snapshotRecoveryCycleMethodTwo(const DataSource&, const CORE::Message&);
81  void processDepthSnapshotMsg(const DataSource&, const CORE::Message&, const MarketSegmentId&);
82  bool processCachedIncrementals();
83 
84  void clearProductDataRepositories();
85 
86  bool filterSecurityId(const SecurityId& securityId) const;
87 
88  bool shouldBuildInternalOrderBooks () const { return config_.settings.buildInternalOrderBooks; }
89  bool shouldStartRecoveryOnPacketGap() const { return config_.settings.startRecoveryOnPacketGap; }
90 
91 
92  void processBeacon(const CORE::Message&, bool*);
93 
94 
95 private:
96  bool recoveryStarted_;
97  MarketSegmentId firstMarketSegmentId_;
98  SequenceNumber lastSnapshotPacketSeqNum_;
99  bool recoveryCycleStarted_;
100  bool recoveryCycleFinished_;
101 
102  typedef std::set<MarketSegmentId> MarketSegmentIdFilters_;
103  MarketSegmentIdFilters_ marketSegmentIdfilters_;
104 
105  SecurityIdFilters securityIdFilters_;
106 
107  std::set<SecurityId> securityIDs_;
108  std::set<MarketSegmentId> marketSegmentIDs_;
109 
110  typedef std::map<MarketSegmentId, MarketDepth> MarketSegmentId2Depth_;
111  MarketSegmentId2Depth_ marketSegmentId2Depth_;
112 
113 
114  std::vector<EmdiProductDataRepository*> productDataRepositories_;
115  boost::function<void (const DataSource&, const CORE::Message&)> snapsotRecoveryCycle_;
116 
117 private:
118  friend struct TestHelpers::EmdiDataRepositoryAccessor;
119 
120  typedef std::map<MarketSegmentId, EmdiProductDataRepository*> EmdiProductDataRepositories_;
121  EmdiProductDataRepositories_ productDataRepositories();
122 };
123 
124 
125 }}}}
126 
unsigned int SequenceNumber
Alias for sequence numbers.
MarketDepthTraits::MarketSegmentId2Depth MarketSegmentId2Depth
Definition: Defines.h:30
FilteringTraits::MarketSegmentIdFilters MarketSegmentIdFilters
Int64 SecurityId
Alias for Security Id type.
Definition: Defines.h:51
DataRepositoryConfig< ListenerHolder, EmdiHandlerSettings > EmdiDataRepositoryConfig
FilteringTraits::SecurityIdFilters SecurityIdFilters
UInt32 MarketSegmentId
Alias for Market Segment ID type.
Definition: Defines.h:40
OnixS::FIX::Core::FAST::TemplateId TemplateId