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  typedef int SocketType;
22 
24  typedef MD::MD_Message MsgType;
25 
33  typedef void (*MessageCallback)(const std::string& topic,
34  MsgType& msg,
35  void* closure);
36 
45  typedef void (*EventCallback)(const Event& e, void* closure);
46 
55  typedef void(*LoggingCallback)(const LogMessage *messages, size_t count);
56 
58  const static int NO_TIMEOUT = 0;
59 
62  const static int HWM_UNLIMITED = 0;
63 
66  enum SnapshotMode {
68  REQUIRE_SNAPSHOT
69  };
70 
73  enum DataMode {
74  LIVE,
76  CANNED
77  };
78 
87  static Error log_open(const std::string& filename, bool append);
88 
91  static void log_close();
92 
95  static void enable_verbose_logging();
96 
99  static void disable_verbose_logging();
100 
105  static void set_logging_callback(LoggingCallback callback);
106 
118  bool connected() const;
119 
126  bool authenticated() const;
127 
134  bool logged_in() const;
135 
143  bool is_subscribed(const std::string& topic) const;
144 
150  unsigned int timeout_sec() const;
151 
157  unsigned int snapshot_timeout_sec() const;
158 
164  unsigned int heartbeat_timeout_sec() const;
165 
171  unsigned int heartbeat_interval_sec() const;
172 
178  unsigned int max_snapshot_queue_size() const;
179 
187  void event_cb(EventCallback callback);
188 
194  void event_cb(EventCallback callback, void* closure);
195 
203  void timeout_sec(unsigned int seconds);
204 
210  void snapshot_timeout_sec(unsigned int seconds);
211 
217  void heartbeat_timeout_sec(unsigned int seconds);
218 
223  void heartbeat_interval_sec(unsigned int seconds);
224 
233  void max_snapshot_queue_size(unsigned int size);
234 
266  void enable_latency_tracking(unsigned int bucket_interval_sec);
267 
272  void disable_latency_tracking();
273 
297  Error register_callback(const std::string& topic_prefix,
299  void* closure,
300  SocketType& fd_out);
301 
308  Error unregister_callback(const std::string& topic_prefix);
309 
315  Error unregister_callback(SocketType fd);
316 
329  Error get_notify_socket(const std::string& topic_prefix,
330  SocketType& fd_out);
331 
344  Error dispatch(long timeout_ms);
345 
357  Error dispatch_fd(SocketType fd);
358 
369  void set_notify_queue_message_limit(size_t limit);
370 
377  size_t get_notify_queue_message_limit();
378 
387  void set_notify_queue_time_limit_ms(int limit);
388 
395  int get_notify_queue_time_limit_ms();
396 
424  FEConsumer(int sub_count, int worker_count, int high_watermark);
425 
434  FEConsumer(int sub_count, int worker_count);
435 
436  ~FEConsumer();
437 
445 
451  Error stop();
452 
473  Error authenticate(const std::string& host,
474  const std::string& user,
475  const std::string& serial,
476  const std::string& key_id,
477  const std::string& key,
478  const std::string& counter,
479  const std::string& path,
480  bool force_input);
481 
497  Error authenticate(const std::string& host,
498  const std::string& user,
499  const std::string& key_id,
500  const std::string& key,
501  const std::string& counter,
502  const std::string& path,
503  bool force_input);
504 
510  Error connect();
511 
522  Error disconnect();
523 
530  Error log_in(bool request_files = true);
531 
559  Error subscribe(const std::string& topic,
560  SnapshotMode snapshot_mode,
561  DataMode data_mode);
562 
570  Error unsubscribe(const std::string& topic);
571 
572 
579  Error request_file(const std::string& filename, std::string& contents_out);
580 
581  /*// Sets the message callback to be called when recovery data is received
582  // If closure is specified, it will be returned when the callback is called
583  Error set_recovery_cb(MessageCallback callback);
584  Error set_recovery_cb(MessageCallback callback, void *closure);
585 
586  Error recover(const std::string &topic, time_t begin_time, time_t end_time);
587  Error recover(const std::string &topic, int begin_seq, int end_seq);*/
588 
590 
598 
602  void stop_async();
603 
609  void authenticate_async(const std::string& host,
610  const std::string& user,
611  const std::string& serial,
612  const std::string& key_id,
613  const std::string& key,
614  const std::string& counter,
615  const std::string& path,
616  bool force_input);
617 
622  void authenticate_async(const std::string& host,
623  const std::string& user,
624  const std::string& key_id,
625  const std::string& key,
626  const std::string& counter,
627  const std::string& path,
628  bool force_input);
629 
632  void connect_async();
633 
636  void disconnect_async();
637 
640  void log_in_async(bool request_files = true);
641 
644  void subscribe_async(const std::string& topic,
645  SnapshotMode snapshot_mode,
646  DataMode data_mode);
647 
650  void unsubscribe_async(const std::string& topic);
651 
654  void request_file_async(const std::string& filename);
655 
656  /*// Sets the message callback to be called when recovery data is received
657  // If closure is specified, it will be returned when the callback is called
658  void set_recovery_cb_async(MessageCallback callback);
659  void set_recovery_cb_async(MessageCallback callback, void *closure);
660 
661  void recover_async(const std::string &topic, time_t begin_time, time_t
662  end_time); void recover_async(const std::string &topic, int begin_seq, int
663  end_seq);*/
664 
666 
667  private:
668  FDSFE_LOCAL FEConsumer(const FEConsumer& not_copyable);
669  FDSFE_LOCAL FEConsumer& operator=(const FEConsumer& not_copyable);
670 
671  FEConsumerImpl* m_impl;
672 };
673 } // namespace Datafeed
674 } // namespace FactSet
675 #endif
No snapshots will be requested.
Definition: FEConsumer.h:67
MD::MD_Message MsgType
Market data message type.
Definition: FEConsumer.h:24
Definition: Event.h:12
void(* MessageCallback)(const std::string &topic, MsgType &msg, void *closure)
Callback signature for receiving market data messages.
Definition: FEConsumer.h:33
DataMode
Set of possible data modes when subscribing.
Definition: FEConsumer.h:73
Delayed market data will be requested.
Definition: FEConsumer.h:75
SnapshotMode
Set of possible snapshot modes when subscribing.
Definition: FEConsumer.h:66
Live realtime market data will be requested.
Definition: FEConsumer.h:74
Definition: LogMessage.h:11
FEConsumer is a class which serves as the primary interface for interacting with the broadcast server...
Definition: FEConsumer.h:18
int SocketType
Operating system file descriptor type.
Definition: FEConsumer.h:21
Definition: Error.h:10