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 "FdsfeApi.h"
8 #include "LogMessage.h"
9 #include "MD/MD_mInt.h"
10 
11 namespace FactSet {
12 namespace Datafeed {
13 struct FEConsumerImpl;
18 class FDSFE_API FEConsumer {
19  public:
21  #ifdef __linux__
22  typedef int SocketType;
23  #elif _WIN32
24  typedef SOCKET SocketType;
25  #endif
26 
28  typedef MD::MD_Message MsgType;
29 
37  typedef void (*MessageCallback)(const std::string& topic,
38  MsgType& msg,
39  void* closure);
40 
49  typedef void (*EventCallback)(const Event& e, void* closure);
50 
59  typedef void(*LoggingCallback)(const LogMessage *messages, size_t count);
60 
62  //Changes to this value need to be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
63  const static int NO_TIMEOUT = 0;
64 
67  //Changes to this value need to be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
68  const static int HWM_UNLIMITED = 0;
69 
72  enum SnapshotMode {
73  //Any changes made to this enum should be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
75  REQUIRE_SNAPSHOT
76  };
77 
80  enum DataMode {
81  //Any changes made to this enum should be duplicated in ../../cpp_toolkit_c_sharp_wrapper/FEConsumer.cs
82  LIVE,
84  CANNED
85  };
86 
89  enum DataSource {
92  COUNT
93  };
94 
103  static Error log_open(const std::string& filename, bool append);
104 
107  static void log_close();
108 
111  static void enable_verbose_logging();
112 
115  static void disable_verbose_logging();
116 
121  static void set_logging_callback(LoggingCallback callback);
122 
134  bool connected() const;
135 
142  bool authenticated() const;
143 
150  bool logged_in() const;
151 
159  bool is_subscribed(const std::string& topic) const;
160 
166  unsigned int timeout_sec() const;
167 
173  unsigned int snapshot_timeout_sec() const;
174 
180  unsigned int heartbeat_timeout_sec() const;
181 
186  unsigned int heartbeat_interval_sec() const;
187 
193  unsigned int max_snapshot_queue_size() const;
194 
202  void event_cb(EventCallback callback);
203 
209  void event_cb(EventCallback callback, void* closure);
210 
218  void timeout_sec(unsigned int seconds);
219 
225  void snapshot_timeout_sec(unsigned int seconds);
226 
232  void heartbeat_timeout_sec(unsigned int seconds);
233 
238  void heartbeat_interval_sec(unsigned int seconds);
239 
248  void max_snapshot_queue_size(unsigned int size);
249 
281  void enable_latency_tracking(unsigned int bucket_interval_sec);
282 
287  void disable_latency_tracking();
288 
312  Error register_callback(const std::string& topic_prefix,
314  void* closure,
315  SocketType& fd_out);
316 
317  Error register_callback(const std::string& topic_prefix,
319  void* closure,
320  DataSource source,
321  SocketType& fd_out);
322 
329  Error unregister_callback(const std::string& topic_prefix);
330  Error unregister_callback(const std::string& topic_prefix,
331  DataSource source);
332 
338  Error unregister_callback(SocketType fd);
339 
352  Error get_notify_socket(const std::string& topic_prefix,
353  SocketType& fd_out);
354 
355  Error get_notify_socket(const std::string& topic_prefix,
356  FEConsumer::DataSource source,
357  SocketType& fd_out);
358 
371  Error dispatch(long timeout_ms);
372 
384  Error dispatch_fd(SocketType fd);
385 
396  void set_notify_queue_message_limit(size_t limit);
397 
404  size_t get_notify_queue_message_limit();
405 
414  void set_notify_queue_time_limit_ms(int limit);
415 
422  int get_notify_queue_time_limit_ms();
423 
451  FEConsumer(int sub_count, int worker_count, int high_watermark);
452 
461  FEConsumer(int sub_count, int worker_count);
462 
463  ~FEConsumer();
464 
472 
478  Error stop();
479 
500  Error authenticate(const std::string& host,
501  const std::string& user,
502  const std::string& serial,
503  const std::string& key_id,
504  const std::string& key,
505  const std::string& counter,
506  const std::string& path,
507  bool force_input);
508 
524  Error authenticate(const std::string& host,
525  const std::string& user,
526  const std::string& key_id,
527  const std::string& key,
528  const std::string& counter,
529  const std::string& path,
530  bool force_input);
531 
537  Error connect();
538 
549  Error disconnect();
550 
557  Error log_in(bool request_files = true);
558 
586  Error subscribe(const std::string& topic,
587  SnapshotMode snapshot_mode,
588  DataMode data_mode);
589 
597  Error unsubscribe(const std::string& topic);
598 
599 
606  Error request_file(const std::string& filename, std::string& contents_out);
607 
608  Error recover(const std::string& topic,
609  time_t begin_time,
610  time_t end_time,
611  FEConsumer::DataMode data_mode);
612 
614 
622 
626  void stop_async();
627 
633  void authenticate_async(const std::string& host,
634  const std::string& user,
635  const std::string& serial,
636  const std::string& key_id,
637  const std::string& key,
638  const std::string& counter,
639  const std::string& path,
640  bool force_input);
641 
646  void authenticate_async(const std::string& host,
647  const std::string& user,
648  const std::string& key_id,
649  const std::string& key,
650  const std::string& counter,
651  const std::string& path,
652  bool force_input);
653 
656  void connect_async();
657 
660  void disconnect_async();
661 
664  void log_in_async(bool request_files = true);
665 
668  void subscribe_async(const std::string& topic,
669  SnapshotMode snapshot_mode,
670  DataMode data_mode);
671 
674  void unsubscribe_async(const std::string& topic);
675 
678  void request_file_async(const std::string& filename);
679 
680  void recover_async(const std::string& topic,
681  time_t begin_time,
682  time_t end_time,
683  FEConsumer::DataMode data_mode);
684 
686 
687  private:
688  FDSFE_LOCAL FEConsumer(const FEConsumer& not_copyable);
689  FDSFE_LOCAL FEConsumer& operator=(const FEConsumer& not_copyable);
690  friend struct FEConsumerImpl;
691  FEConsumerImpl* m_impl;
692 };
693 } // namespace Datafeed
694 } // namespace FactSet
695 #endif
No snapshots will be requested.
Definition: FEConsumer.h:74
DataSource
Set of possible data sources when registering callbacks.
Definition: FEConsumer.h:89
MD::MD_Message MsgType
Operating system file descriptor type.
Definition: FEConsumer.h:28
Definition: Event.h:12
void(* MessageCallback)(const std::string &topic, MsgType &msg, void *closure)
Callback signature for receiving market data messages.
Definition: FEConsumer.h:37
DataMode
Set of possible data modes when subscribing.
Definition: FEConsumer.h:80
Market data from subscribe.
Definition: FEConsumer.h:90
Delayed market data will be requested.
Definition: FEConsumer.h:83
SnapshotMode
Set of possible snapshot modes when subscribing.
Definition: FEConsumer.h:72
Live realtime market data will be requested.
Definition: FEConsumer.h:82
Definition: LogMessage.h:11
Recovery data from recover.
Definition: FEConsumer.h:91
FEConsumer is a class which serves as the primary interface for interacting with the broadcast server...
Definition: FEConsumer.h:18
Definition: Error.h:10