Apama Capital Markets Foundation 10.15.0.0
Connectivity_MDInterfaces.h
Go to the documentation of this file.
1
9#ifndef _SAG_MDM_INTERFACE_H_
10#define _SAG_MDM_INTERFACE_H_
11
12/* The timestamp tags are tempararily allocated
13
14TIMESTAMP_UPSTREAM_MDM_ENTRY 19800
15TIMESTAMP_UPSTREAM_MDM_EXIT 19850
16
17TIMESTAMP_DOWNSTREAM_MDM_ENTRY 1100
18TIMESTAMP_DOWNSTREAM_MDM_EXIT 1150
19*/
20
21#include <string>
22#include<memory>
23#include <vector>
24#include <list>
25#include <set>
26#include "sag_connectivity_plugins.hpp"
27
28using namespace com::softwareag::connectivity;
29
30
31
32#if defined(_APBUILD_WIN32_ALL__) || defined(__WIN32__) || defined(WIN32)
33/*
34* DLL import/export symbols for Win32 builds. Everything will work correctly
35* as long as the following symbols are *not* defined when this file is
36* included (These symbols are for Apama external use only):
37* SAG_MDM_BACKEND
38*/
39
40#ifndef _APBUILD_WIN32_ALL__
41#define _APBUILD_WIN32_ALL__
42#endif
43
44#ifdef SAG_MDM_BACKEND
45#define SAG_MDM_API __declspec(dllexport)
46#define SAG_MDM_CALL __stdcall
47#else
48#define SAG_MDM_API __declspec(dllimport)
49#define SAG_MDM_CALL __stdcall
50#endif
51
52#elif defined(_APBUILD_UNIX_ALL__) || defined(__unix__)
53#define SAG_MDM_API
54#define SAG_MDM_CALL
55#else
56#error "Can't determine platform: try #define _APBUILD_WIN32_ALL__ or _APBUILD_UNIX_ALL__"
57#endif
58
59namespace com {
60 namespace softwareag {
61 namespace marketdata {
62
63#define STREAMTYPE_BBA ("com.apama.md.BBA")
64#define STREAMTYPE_TRADE ("com.apama.md.T")
65#define STREAMTYPE_MBP ("com.apama.md.D")
66#define STREAMTYPE_MBO ("com.apama.md.O")
67#define STREAMTYPE_EP ("com.apama.md.EP")
68#define STREAMTYPE_QUOTEBOOK ("com.apama.md.QB")
69#define STREAMTYPE_NEWS ("com.apama.md.N")
72 typedef enum {
80 MDM_NEWS_STREAM = 128
81 }
83
84
85
86#define MDM_DEFAULT_STRING "~#"
87#define MDM_DEFAULT_FLOAT 0.000001
88#define MDM_DEFAULT_INT -999999
91 typedef enum {
94 }
96
98 typedef enum {
102 MDM_INFO
105
106
107 typedef std::vector<std::string> StringList;
108 typedef std::set<std::string> StringSet;
112 {
113 public:
118 SchemaItemValue(const std::string &paramName, const std::string &value) : paramName_(paramName), value_(value) {}
119
123 bool operator==(const SchemaItemValue& rhs) const { return (paramName_ == rhs.paramName_) && (value_ == rhs.value_); }
124
125 std::string paramName_;
126 std::string value_;
127 };
128
131 {
132 public:
139 SchemaItem(const std::string &paramName, const std::string &type, const std::string &value, const std::string &description)
140 : SchemaItemValue(paramName, value)
141 , type_(type)
142 , description_(description)
143 {}
144
145 std::string type_;
146 std::string description_;
147 };
148
151 typedef std::list<ExtraParam> ExtraParamList;
152 typedef std::list<ExtraParamValue> ExtraParamValueList;
155 typedef std::list<NewsData> NewsDataList;
158 typedef std::vector<StringPair> StringDictionary;
161 typedef struct timeStampConfig{
167 //enum AP_LogLevel logLevel;
168
170 : recordUpstream(false)
171 , recordDownstream(false)
172 , logUpstream(false)
173 , logDownstream(false)
174 , logRoundtrip(false)
175 {
176 };
177 } TimestampConfig;
178
179
181 class MarketDataSession;
182 typedef int64_t TimestampSetIndex;
183 typedef double TimestampSetTime;
186 class TimestampSet;
187 typedef std::shared_ptr<TimestampSet> TimestampSetPtr;
190 class SAG_MDM_API MDMInterface
191 {
192 public:
198
199 virtual ~MDMInterface() {}
200
216 virtual const char* getKey(const std::string& symbol, int64_t sourceId, AP_MDM_StreamType streamType, map_t& ctrlParams) = 0;
217
230 virtual void connect(const std::string& subKey, AP_MDM_StreamType streamType, map_t& ctrlParams) = 0;
231
244 virtual void disconnect(const std::string& subKey, AP_MDM_StreamType streamType, map_t& ctrlParams) = 0;
245
254 virtual void setMarketDataSession(MarketDataSession* mdSession) = 0;
255
256 };
257
259 class SAG_MDM_API MarketDataManager
260 {
261
262 public:
270 MarketDataManager(Logger* logger, MDMInterface* mdIface);
271
272 virtual ~MarketDataManager();
273
277 virtual void Start() = 0;
278
282 virtual void Stop() = 0;
283
289 virtual bool ProcessMessage(Message& msgObj) = 0;
290
291
302 virtual void setHostSide(HostSide* hostSide);
303
312 virtual void setTimeStampConfig(map_t& timeStampConfig) = 0;
313
314 protected:
316 HostSide* hostSide_;
318 Logger* logger_;
321 };
322
325
327 class SAG_MDM_API MDManagerFactory {
328 public:
336 static MarketDataManager* createMarketDataManager(Logger* logger, MDMInterface* mdmConntInterface);
337 };
338
342 class SAG_MDM_API MarketDataSession {
343 public:
344
345 virtual ~MarketDataSession() {};
346
354 virtual void setConnectSuccess(const std::string& subKey, TimestampSetPtr tss) = 0;
355
364 virtual void setConnectFailed(const std::string& subKey, const std::string& description, TimestampSetPtr tss) = 0;
365
373 virtual void setDisconnectSuccess(const std::string& subKey, TimestampSetPtr tss) = 0;
374
383 virtual void setDisconnectFailed(const std::string& subKey, const std::string & description, TimestampSetPtr tss) = 0;
384
392 virtual void SubscriptionCommit(const std::string& subKey, TimestampSetPtr tss) = 0;
393
399 virtual void RemoveSubscription(const std::string& subKey) = 0;
400
406 virtual void RemoveSourceSubscriptions(int64_t sourceId) = 0;
407
411 virtual void RemoveSubscriptions() = 0;
412
421 virtual void ClearSubscriptionData(const std::string& subKey) = 0;
422
423
432 virtual void ClearSourceData(int64_t sourceId) = 0;
433
438 virtual void ClearData() = 0;
439
444 };
445
446
448 class SAG_MDM_API TimestampSet
449 {
450 public:
455 ~TimestampSet() { _timeStampmap.clear(); }
456
463
471
479
484 map_t& getTimeStamp() { return _timeStampmap; }
485
486 private:
487 //key -> index
488 //val -> time(double)
489 map_t _timeStampmap;
490 TimestampSetTime getRelativeTime();
491 };
492 }
493 }
494}
495
496#endif /*_SAG_MDM_INTERFACE_H_*/
std::shared_ptr< TimestampSet > TimestampSetPtr
Definition: Connectivity_MDInterfaces.h:186
int64_t TimestampSetIndex
Definition: Connectivity_MDInterfaces.h:181
AP_MDM_StreamType
Definition: Connectivity_MDInterfaces.h:72
double TimestampSetTime
Definition: Connectivity_MDInterfaces.h:183
SchemaItem NewsData
Definition: MDM_MarketDataInterface.h:227
std::list< NewsData > NewsDataList
Definition: MDM_MarketDataInterface.h:228
std::vector< StringPair > StringDictionary
Definition: MDM_MarketDataInterface.h:231
std::list< ExtraParam > ExtraParamList
Definition: MDM_MarketDataInterface.h:224
SchemaItemValue ExtraParamValue
Definition: MDM_MarketDataInterface.h:223
std::set< std::string > StringSet
Definition: MDM_MarketDataInterface.h:181
AP_MDM_StreamType
Definition: MDM_MarketDataInterface.h:62
@ MDM_EP_STREAM
Definition: MDM_MarketDataInterface.h:68
@ MDM_NEWS_STREAM
Definition: MDM_MarketDataInterface.h:70
@ MDM_BBA_STREAM
Definition: MDM_MarketDataInterface.h:64
@ MDM_UNKNOWN_STREAM
Definition: MDM_MarketDataInterface.h:63
@ MDM_MBP_STREAM
Definition: MDM_MarketDataInterface.h:66
@ MDM_QUOTEBOOK_STREAM
Definition: MDM_MarketDataInterface.h:69
@ MDM_TRADE_STREAM
Definition: MDM_MarketDataInterface.h:65
@ MDM_MBO_STREAM
Definition: MDM_MarketDataInterface.h:67
AP_MDM_TransferMode
Definition: MDM_MarketDataInterface.h:79
@ MDM_COMPOUND_DELTA
Definition: MDM_MarketDataInterface.h:80
@ MDM_SNAPSHOT_ONLY
Definition: MDM_MarketDataInterface.h:81
SchemaItemValue StringPair
Definition: MDM_MarketDataInterface.h:230
SchemaItem ExtraParam
Definition: MDM_MarketDataInterface.h:222
std::vector< std::string > StringList
Definition: MDM_MarketDataInterface.h:180
AP_MDM_ErrorLevel
Definition: MDM_MarketDataInterface.h:86
@ MDM_INFO
Definition: MDM_MarketDataInterface.h:90
@ MDM_WARNING
Definition: MDM_MarketDataInterface.h:89
@ MDM_FATAL
Definition: MDM_MarketDataInterface.h:87
@ MDM_ERROR
Definition: MDM_MarketDataInterface.h:88
std::list< ExtraParamValue > ExtraParamValueList
Definition: MDM_MarketDataInterface.h:225
Definition: Connectivity_MDInterfaces.h:191
virtual const char * getKey(const std::string &symbol, int64_t sourceId, AP_MDM_StreamType streamType, map_t &ctrlParams)=0
virtual void connect(const std::string &subKey, AP_MDM_StreamType streamType, map_t &ctrlParams)=0
virtual void setMarketDataSession(MarketDataSession *mdSession)=0
virtual void disconnect(const std::string &subKey, AP_MDM_StreamType streamType, map_t &ctrlParams)=0
MDMInterface()
Definition: Connectivity_MDInterfaces.h:197
Definition: Connectivity_MDInterfaces.h:327
static MarketDataManager * createMarketDataManager(Logger *logger, MDMInterface *mdmConntInterface)
Definition: Connectivity_MDInterfaces.h:260
HostSide * hostSide_
Definition: Connectivity_MDInterfaces.h:316
MDMInterface * mdInterface_
Definition: Connectivity_MDInterfaces.h:320
MarketDataManager(Logger *logger, MDMInterface *mdIface)
virtual void setTimeStampConfig(map_t &timeStampConfig)=0
virtual void setHostSide(HostSide *hostSide)
virtual bool ProcessMessage(Message &msgObj)=0
Logger * logger_
Definition: Connectivity_MDInterfaces.h:318
Definition: Connectivity_MDPublisher.h:23
Definition: Connectivity_MDInterfaces.h:342
virtual void setConnectSuccess(const std::string &subKey, TimestampSetPtr tss)=0
virtual void ClearSourceData(int64_t sourceId)=0
virtual void setDisconnectSuccess(const std::string &subKey, TimestampSetPtr tss)=0
virtual void setDisconnectFailed(const std::string &subKey, const std::string &description, TimestampSetPtr tss)=0
virtual MarketDataPublisher * getPublisher(AP_MDM_StreamType stype)=0
virtual void setConnectFailed(const std::string &subKey, const std::string &description, TimestampSetPtr tss)=0
virtual void ClearSubscriptionData(const std::string &subKey)=0
virtual void SubscriptionCommit(const std::string &subKey, TimestampSetPtr tss)=0
virtual void RemoveSubscription(const std::string &subKey)=0
virtual void RemoveSourceSubscriptions(int64_t sourceId)=0
Definition: Connectivity_MDInterfaces.h:131
std::string type_
Definition: Connectivity_MDInterfaces.h:145
std::string description_
Definition: Connectivity_MDInterfaces.h:146
SchemaItem(const std::string &paramName, const std::string &type, const std::string &value, const std::string &description)
Definition: Connectivity_MDInterfaces.h:139
Definition: Connectivity_MDInterfaces.h:112
std::string value_
Definition: Connectivity_MDInterfaces.h:126
SchemaItemValue(const std::string &paramName, const std::string &value)
Definition: Connectivity_MDInterfaces.h:118
bool operator==(const SchemaItemValue &rhs) const
Definition: Connectivity_MDInterfaces.h:123
std::string paramName_
Definition: Connectivity_MDInterfaces.h:125
Definition: Connectivity_MDInterfaces.h:449
TimestampSet()
Definition: Connectivity_MDInterfaces.h:454
map_t & getTimeStamp()
Definition: Connectivity_MDInterfaces.h:484
void addTime(TimestampSetIndex index, TimestampSetTime time)
void addNow(TimestampSetIndex index)
TimestampSetTime findTime(TimestampSetIndex index)
Definition: Connectivity_MDInterfaces.h:161
bool recordUpstream
Definition: Connectivity_MDInterfaces.h:162
bool logRoundtrip
Definition: Connectivity_MDInterfaces.h:166
bool logUpstream
Definition: Connectivity_MDInterfaces.h:164
bool logDownstream
Definition: Connectivity_MDInterfaces.h:165
bool recordDownstream
Definition: Connectivity_MDInterfaces.h:163