Apama Capital Markets Foundation  10.1.0.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
14 TIMESTAMP_UPSTREAM_MDM_ENTRY 19800
15 TIMESTAMP_UPSTREAM_MDM_EXIT 19850
16 
17 TIMESTAMP_DOWNSTREAM_MDM_ENTRY 1100
18 TIMESTAMP_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 
28 using 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 
59 namespace 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 {
73  MDM_UNKNOWN_STREAM = 0,
74  MDM_BBA_STREAM = 1,
75  MDM_TRADE_STREAM = 2,
76  MDM_MBP_STREAM = 8,
77  MDM_MBO_STREAM = 16,
78  MDM_EP_STREAM = 32,
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 {
92  MDM_COMPOUND_DELTA = 1,
94  }
96 
98  typedef enum {
99  MDM_FATAL,
100  MDM_ERROR,
101  MDM_WARNING,
102  MDM_INFO
103  }
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 
149  typedef SchemaItem ExtraParam;
151  typedef std::list<ExtraParam> ExtraParamList;
152  typedef std::list<ExtraParamValue> ExtraParamValueList;
154  typedef SchemaItem NewsData;
155  typedef std::list<NewsData> NewsDataList;
157  typedef SchemaItemValue StringPair;
158  typedef std::vector<StringPair> StringDictionary;
161  typedef struct timeStampConfig{
164  bool logUpstream;
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 
324  class MarketDataPublisher;
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 
443  virtual MarketDataPublisher* getPublisher(AP_MDM_StreamType stype) = 0;
444  };
445 
446 
448  class SAG_MDM_API TimestampSet
449  {
450  public:
455  ~TimestampSet() { _timeStampmap.clear(); }
456 
462  void addNow(TimestampSetIndex index);
463 
470  void addTime(TimestampSetIndex index, TimestampSetTime time);
471 
478  TimestampSetTime findTime(TimestampSetIndex index);
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_*/
Definition: Connectivity_MDInterfaces.h:448
std::vector< StringPair > StringDictionary
Definition: MDM_MarketDataInterface.h:231
HostSide * hostSide_
Definition: Connectivity_MDInterfaces.h:316
TimestampSet()
Definition: Connectivity_MDInterfaces.h:454
Definition: MDM_MarketDataInterface.h:63
Definition: MDM_MarketDataInterface.h:90
SchemaItemValue StringPair
Definition: MDM_MarketDataInterface.h:230
AP_MDM_ErrorLevel
Definition: MDM_MarketDataInterface.h:86
Definition: Connectivity_MDPublisher.h:22
bool logDownstream
Definition: Connectivity_MDInterfaces.h:165
Definition: MDM_MarketDataInterface.h:68
Definition: MDM_MarketDataInterface.h:88
std::string type_
Definition: Connectivity_MDInterfaces.h:145
SchemaItem NewsData
Definition: MDM_MarketDataInterface.h:227
Definition: Connectivity_MDInterfaces.h:59
bool logRoundtrip
Definition: Connectivity_MDInterfaces.h:166
bool recordDownstream
Definition: Connectivity_MDInterfaces.h:163
AP_MDM_StreamType
Definition: MDM_MarketDataInterface.h:62
std::list< NewsData > NewsDataList
Definition: MDM_MarketDataInterface.h:228
std::set< std::string > StringSet
Definition: MDM_MarketDataInterface.h:181
Logger * logger_
Definition: Connectivity_MDInterfaces.h:318
SchemaItemValue ExtraParamValue
Definition: MDM_MarketDataInterface.h:223
Definition: MDM_MarketDataInterface.h:70
Definition: MDM_MarketDataInterface.h:64
SchemaItemValue(const std::string &paramName, const std::string &value)
Definition: Connectivity_MDInterfaces.h:118
std::string paramName_
Definition: Connectivity_MDInterfaces.h:125
SchemaItem ExtraParam
Definition: MDM_MarketDataInterface.h:222
MDMInterface * mdInterface_
Definition: Connectivity_MDInterfaces.h:320
Definition: Connectivity_MDInterfaces.h:342
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
MDMInterface()
Definition: Connectivity_MDInterfaces.h:197
Definition: MDM_MarketDataInterface.h:67
Definition: Connectivity_MDInterfaces.h:161
std::vector< std::string > StringList
Definition: MDM_MarketDataInterface.h:180
Definition: MDM_MarketDataInterface.h:80
AP_MDM_TransferMode
Definition: MDM_MarketDataInterface.h:79
bool operator==(const SchemaItemValue &rhs) const
Definition: Connectivity_MDInterfaces.h:123
Definition: Connectivity_MDInterfaces.h:190
bool logUpstream
Definition: Connectivity_MDInterfaces.h:164
map_t & getTimeStamp()
Definition: Connectivity_MDInterfaces.h:484
Definition: MDM_MarketDataInterface.h:65
Definition: Connectivity_MDInterfaces.h:130
Definition: MDM_MarketDataInterface.h:66
Definition: Connectivity_MDInterfaces.h:259
Definition: Connectivity_MDInterfaces.h:327
Definition: MDM_MarketDataInterface.h:87
Definition: Connectivity_MDInterfaces.h:111
Definition: MDM_MarketDataInterface.h:89
std::string value_
Definition: Connectivity_MDInterfaces.h:126
std::list< ExtraParamValue > ExtraParamValueList
Definition: MDM_MarketDataInterface.h:225
Definition: MDM_MarketDataInterface.h:81
Definition: MDM_MarketDataInterface.h:69
bool recordUpstream
Definition: Connectivity_MDInterfaces.h:162
std::list< ExtraParam > ExtraParamList
Definition: MDM_MarketDataInterface.h:224