Broadcast C++ Toolkit
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
FEConsumer.h
1 #ifndef __FECONSUMER_H__
2 #define __FECONSUMER_H__
3 
4 #include <string>
5 #include "Error.h"
6 #include "Event.h"
7 #include "FEConsumerOptions.h"
8 #include "FdsfeApi.h"
9 #include "LogMessage.h"
10 #include "MD/MD_mInt.h"
11 
12 namespace FactSet {
13 namespace Datafeed {
14 struct FEConsumerImpl;
15 
20 class FDSFE_API FEConsumer {
21  public:
23  #ifdef __linux__
24  typedef int SocketType;
25  #elif _WIN32
26  typedef SOCKET SocketType;
27  #endif
28 
30  typedef MD::MD_Message MsgType;
31 
39  typedef void (*MessageCallback)(const std::string& topic,
40  MsgType& msg,
41  void* closure);
42 
51  typedef void (*EventCallback)(const Event& e, void* closure);
52 
61  typedef void(*LoggingCallback)(const LogMessage *messages, size_t count);
62 
64  //Changes to this value need to be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
65  //and ../../cpp_toolkit_c_wrapper/FEConsumer_C.h
66  const static int NO_TIMEOUT = 0;
67 
70  //Changes to this value need to be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
71  //and ../../cpp_toolkit_c_wrapper/FEConsumer_C.h
72  const static int HWM_UNLIMITED = 0;
73 
76  enum SnapshotMode {
77  //Any changes made to this enum should be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
78  // and ../../cpp_toolkit_c_wrapper/include/FEConsumer_C.h
80  REQUIRE_SNAPSHOT
81  };
82 
85  enum DataMode {
86  //Any changes made to this enum should be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
87  // and ../../cpp_toolkit_c_wrapper/include/FEConsumer_C.h
88  LIVE,
90  CANNED
91  };
92 
95  enum DataSource {
96  //Any changes made to this enum should be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
97  // and ../../cpp_toolkit_c_wrapper/include/FEConsumer_C.h
101  COUNT
102  };
103 
112  static Error log_open(const std::string& filename, bool append);
113 
116  static void log_close();
117 
120  static void enable_verbose_logging();
121 
124  static void disable_verbose_logging();
125 
130  static void set_logging_callback(LoggingCallback callback);
131 
143  bool connected() const;
144 
151  bool authenticated() const;
152 
159  bool logged_in() const;
160 
168  bool is_subscribed(const std::string& topic) const;
169 
175  unsigned int timeout_sec() const;
176 
182  unsigned int snapshot_timeout_sec() const;
183 
189  unsigned int heartbeat_timeout_sec() const;
190 
195  unsigned int heartbeat_interval_sec() const;
196 
202  unsigned int max_snapshot_queue_size() const;
203 
211  void event_cb(EventCallback callback);
212 
218  void event_cb(EventCallback callback, void* closure);
219 
227  void timeout_sec(unsigned int seconds);
228 
234  void snapshot_timeout_sec(unsigned int seconds);
235 
241  void heartbeat_timeout_sec(unsigned int seconds);
242 
247  void heartbeat_interval_sec(unsigned int seconds);
248 
259  void max_snapshot_queue_size(unsigned int size);
260 
292  void enable_latency_tracking(unsigned int bucket_interval_sec);
293 
298  void disable_latency_tracking();
299 
323  Error register_callback(const std::string& topic_prefix,
325  void* closure,
326  SocketType& fd_out);
327 
328  Error register_callback(const std::string& topic_prefix,
330  void* closure,
331  DataSource source,
332  SocketType& fd_out);
333 
340  Error unregister_callback(const std::string& topic_prefix);
341  Error unregister_callback(const std::string& topic_prefix,
342  DataSource source);
343 
349  Error unregister_callback(SocketType fd);
350 
363  Error get_notify_socket(const std::string& topic_prefix,
364  SocketType& fd_out);
365 
366  Error get_notify_socket(const std::string& topic_prefix,
367  FEConsumer::DataSource source,
368  SocketType& fd_out);
369 
382  Error dispatch(long timeout_ms);
383 
395  Error dispatch_fd(SocketType fd);
396 
407  void set_notify_queue_message_limit(size_t limit);
408 
415  size_t get_notify_queue_message_limit();
416 
427  void set_notify_queue_time_limit_ms(int limit);
428 
435  int get_notify_queue_time_limit_ms();
436 
465  FEConsumer(int sub_count, int worker_count, int high_watermark, bool enable_compression);
466 
476  FEConsumer(int sub_count, int worker_count, int high_watermark);
477 
486  FEConsumer(int sub_count, int worker_count);
487 
488  FEConsumer(const FEConsumerOptions& options);
489 
490  ~FEConsumer();
491 
499 
505  Error stop();
506 
527  Error authenticate(const std::string& host,
528  const std::string& user,
529  const std::string& serial,
530  const std::string& key_id,
531  const std::string& key,
532  const std::string& counter,
533  const std::string& path,
534  bool force_input);
535 
550  Error authenticate(const std::string& host,
551  const std::string& user,
552  const std::string& key_id,
553  const std::string& key,
554  const std::string& counter,
555  const std::string& path,
556  bool force_input);
557 
563  Error connect();
564 
575  Error disconnect();
576 
582  Error log_in(bool request_files = true);
583 
611  Error subscribe(const std::string& topic,
612  SnapshotMode snapshot_mode,
613  DataMode data_mode);
614 
622  Error unsubscribe(const std::string& topic);
623 
624 
631  Error request_file(const std::string& filename, std::string& contents_out);
632 
633  Error recover(const std::string& topic,
634  time_t begin_time,
635  time_t end_time,
636  FEConsumer::DataMode data_mode);
637 
638  Error request_snapshot(const std::string& topic,
639  FEConsumer::DataMode data_mode);
640 
642 
650 
654  void stop_async();
655 
661  void authenticate_async(const std::string& host,
662  const std::string& user,
663  const std::string& serial,
664  const std::string& key_id,
665  const std::string& key,
666  const std::string& counter,
667  const std::string& path,
668  bool force_input);
669 
674  void authenticate_async(const std::string& host,
675  const std::string& user,
676  const std::string& key_id,
677  const std::string& key,
678  const std::string& counter,
679  const std::string& path,
680  bool force_input);
681 
684  void connect_async();
685 
688  void disconnect_async();
689 
692  void log_in_async(bool request_files = true);
693 
696  void subscribe_async(const std::string& topic,
697  SnapshotMode snapshot_mode,
698  DataMode data_mode);
699 
702  void unsubscribe_async(const std::string& topic);
703 
706  void request_file_async(const std::string& filename);
707 
708  void recover_async(const std::string& topic,
709  time_t begin_time,
710  time_t end_time,
711  FEConsumer::DataMode data_mode);
712 
713  void request_snapshot_async(const std::string& topic,
714  FEConsumer::DataMode data_mode);
715 
717 #ifdef FDS_C_WRAPPER
718  void create_hwm_event(Event::EventType type, const std::string& topic);
719 #endif
720 
721  private:
722  FDSFE_LOCAL FEConsumer(const FEConsumer& not_copyable);
723  FDSFE_LOCAL FEConsumer& operator=(const FEConsumer& not_copyable);
724  friend struct FEConsumerImpl;
725  FEConsumerImpl* m_impl;
726 };
727 } // namespace Datafeed
728 } // namespace FactSet
729 #endif
No snapshots will be requested.
Definition: FEConsumer.h:79
DataSource
Set of possible data sources when registering callbacks.
Definition: FEConsumer.h:95
MD::MD_Message MsgType
Operating system file descriptor type.
Definition: FEConsumer.h:30
Snapshot data from request_out_of_band_snapshot.
Definition: FEConsumer.h:100
Definition: Event.h:12
EventType
Set of possible event types.
Definition: Event.h:21
void(* MessageCallback)(const std::string &topic, MsgType &msg, void *closure)
Callback signature for receiving market data messages.
Definition: FEConsumer.h:39
DataMode
Set of possible data modes when subscribing.
Definition: FEConsumer.h:85
Market data from subscribe.
Definition: FEConsumer.h:98
Delayed market data will be requested.
Definition: FEConsumer.h:89
SnapshotMode
Set of possible snapshot modes when subscribing.
Definition: FEConsumer.h:76
Live realtime market data will be requested.
Definition: FEConsumer.h:88
Definition: FEConsumerOptions.h:12
Definition: LogMessage.h:11
Recovery data from recover.
Definition: FEConsumer.h:99
FEConsumer is a class which serves as the primary interface for interacting with the broadcast server...
Definition: FEConsumer.h:20
Definition: Error.h:10