From d930ee6b9a52f0eb9939b3fe55afd2361944edb2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Fri, 8 Nov 2013 18:14:57 +0100 Subject: add support for ZeroMQ output --- src/dabOutput/dabOutput.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/dabOutput/dabOutput.h') diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h index 7f295b4..a39a6ca 100644 --- a/src/dabOutput/dabOutput.h +++ b/src/dabOutput/dabOutput.h @@ -30,6 +30,7 @@ #include "UdpSocket.h" #include "TcpServer.h" #include "TcpLog.h" +#include #include #ifdef _WIN32 # include @@ -45,6 +46,9 @@ # define O_BINARY 0 # endif // O_BINARY #endif +#ifdef HAVE_OUTPUT_ZEROMQ +# include "zmq.hpp" +#endif extern TcpLog etiLog; @@ -244,5 +248,43 @@ class DabOutputSimul : public DabOutput #endif }; +#if defined(HAVE_OUTPUT_ZEROMQ) +// -------------- ZeroMQ message queue ------------------ +class DabOutputZMQ : public DabOutput +{ + public: + DabOutputZMQ() : + zmq_proto_(""), zmq_context_(1), zmq_pub_sock_(zmq_context_, ZMQ_PUB) + { + throw std::runtime_error("ERROR: No ZMQ protocol specified !"); + } + + DabOutputZMQ(std::string zmq_proto) : + zmq_proto_(zmq_proto), zmq_context_(1), zmq_pub_sock_(zmq_context_, ZMQ_PUB) + { } + + + DabOutputZMQ(const DabOutputZMQ& other) : + zmq_proto_(other.zmq_proto_), zmq_context_(1), zmq_pub_sock_(zmq_context_, ZMQ_PUB) + { + // cannot copy context + } + + ~DabOutputZMQ() + { + zmq_pub_sock_.close(); + } + + int Open(const char* name); + int Write(void* buffer, int size); + int Close(); + private: + std::string zmq_proto_; + zmq::context_t zmq_context_; // handle for the zmq context + zmq::socket_t zmq_pub_sock_; // handle for the zmq publisher socket +}; + +#endif + #endif -- cgit v1.2.3