OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
EobiPacketProcessor.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 
20 #pragma once
21 
22 #include <util/TextBuilder.h>
23 
24 #include "../PacketHeader.h"
26 #include <boost/function.hpp>
27 
28 #include <OnixS/HandlerCore/FeedEngine/SharedReceiver.h>
29 #include <OnixS/HandlerCore/FeedEngine/PacketContainer.h>
30 #include <OnixS/HandlerCore/FeedEngine/SortedPackets.h>
31 #include <OnixS/HandlerCore/MarketData/MulticastFeedHandler.h>
32 
33 
34 #include "../Utils.h"
35 
36 namespace OnixS {
37 namespace Eurex {
38 namespace MarketData {
39 namespace EOBI {
40 namespace Implementation {
41 
42 using namespace HandlerCore::MarketData;
43 
45 {
48 
49  static
50  const PacketHeader* getPacketHeader(const FE::PacketContainer& container);
51 
52  static
53  SequenceNumber_ seqNumber(const FE::PacketContainer& container);
54 
55  static
56  SequenceNumber_ nextSeqNumber(const FE::PacketContainer& container);
57 
58  static
59  bool isHeartbeat(const FE::PacketContainer&);
60 
61  static
62  std::string toString(const FE::PacketContainer& container);
63 
64  static
65  size_t headerSize();
66 };
67 
68 
69 class EobiPacketProcessor : public LegacyLogPlayerPacketProcessor
70 {
72 
73 public:
74  typedef boost::function<void(DataSource& dataSource, const char* data, size_t length)> OnPacketData;
75  typedef boost::function<void()> OnGap;
76  typedef boost::function<void()> OnInactivity;
77  typedef boost::function<void(FE::NetFeedRole::Enum)> OnFeedInactivity;
78  typedef boost::function<void()> OnApplSeqReset;
79 
81  unsigned int maxPacketWaitingTimeInMs,
82  unsigned int inactivityWaitingTimeInSec,
83  unsigned int outOfOrderMaxInterval,
84  Concurrency::RecursiveMutex* lock);
85 
86  virtual ~EobiPacketProcessor() {}
87 
88  void reset() override;
89  bool tryAcquire() override;
90  void release() override;
91  void onPacket(FE::PacketContainer&) override;
92  void onTimeout(const FE::NetFeed&) override;
93  void onFailure(const FE::NetFeed&, const char*) override {}
94  void processHoldOnPackets(const FE::Timestamp& now);
95 
96  void subscribeOnPacketData(const OnPacketData callback);
97  void subscribeOnGap(const OnGap callback);
98  void subscribeOnApplSeqReset(const OnApplSeqReset callback);
99  void subscribeOnInactivity(const OnInactivity callback);
100  void subscribeOnFeedInactivity(const OnFeedInactivity callback);
101 
102 protected:
103  DataSource createDataSource(FE::PacketContainer& packetContainer, SequenceNumber packetSeqNum);
104 
105 protected:
106  OnPacketData onPacketData_;
107  OnGap onGap_;
108  OnApplSeqReset onApplSeqReset_;
109  OnInactivity onInactivity_;
110  OnFeedInactivity onFeedInactivity_;
111 
112 
114 
115  const FE::TimeSpan maxPacketWaitingTimeSpan_;
116  const FE::TimeSpan inactivityWaitingTimeSpan_;
118 
123 
124  FE::Timestamp lastReceptionTimeFe_;
125  FE::Timestamp lastReceptionTimeFeA_;
126  FE::Timestamp lastReceptionTimeFeB_;
127 
128  FE::SortedPackets<PacketHelper> outOfOrder_;
129  OnixS::Concurrency::RecursiveMutex* lock_;
130 };
131 
133 {
135 
136 public:
138  unsigned int maxPacketWaitingTimeInMs,
139  unsigned int inactivityWaitingTimeInSec,
140  unsigned int outOfOrderMaxInterval,
141  Concurrency::RecursiveMutex* lock);
142 
143 public:
144  void onPacket(FE::PacketContainer&) override;
145 };
146 
147 }}}}}
148 
unsigned int SequenceNumber
Alias for sequence numbers.
void onFailure(const FE::NetFeed &, const char *) override
PacketHeaderForEobi PacketHeader
unsigned int UInt32
Definition: Numeric.h:41
Definition: Defines.h:30
boost::function< void(FE::NetFeedRole::Enum)> OnFeedInactivity
MarketData::Implementation::PacketHeaderForEobi PacketHeader
boost::function< void(DataSource &dataSource, const char *data, size_t length)> OnPacketData