Guest User

publisher.hpp

a guest
Feb 27th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. /*
  2.  * The publisher is a singleton that binds sockets where it publishes box
  3.  * state changes for an arbitrary number of (external) subscribers to
  4.  * receive. It shall react on messages from the boxoffice and send the
  5.  * appropriate messages accordingly.
  6.  * Publisher shall only be used within the publisher thread.
  7.  */
  8.  
  9. #ifndef SB_PUBLISHER_HPP
  10. #define SB_PUBLISHER_HPP
  11.  
  12. #include <zmq.hpp>
  13.  
  14. class Publisher
  15. {
  16.   public:
  17.     Publisher(const Publisher&) = delete;
  18.     Publisher& operator=(const Publisher&) = delete;
  19.  
  20.     static Publisher* getInstance()
  21.     {
  22.       static Publisher pub_instance_;
  23.       return &pub_instance_;
  24.     }
  25.  
  26.     static Publisher* initialize(zmq::context_t* z_ctx);
  27.     int sendExitSignal();
  28.  
  29.   private:
  30.     Publisher() :
  31.       z_pub_to_bo(),
  32.       z_bo_to_pub()
  33.       {};
  34.     ~Publisher()
  35.     {
  36.       z_pub_to_bo->close();
  37.       z_bo_to_pub->close();
  38.     }
  39.  
  40.     int connectToBoxoffice(zmq::context_t* z_ctx);
  41.  
  42.     zmq::socket_t* z_pub_to_bo;
  43.     zmq::socket_t* z_bo_to_pub;
  44. };
  45.  
  46. #endif
Advertisement
Add Comment
Please, Sign In to add comment