diff options
author | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-08 18:14:57 +0100 |
---|---|---|
committer | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-08 18:14:57 +0100 |
commit | d930ee6b9a52f0eb9939b3fe55afd2361944edb2 (patch) | |
tree | a26c6c31bebe6681da54d9acd782c3fe96969da7 /src/dabOutput/dabOutput.h | |
parent | c5306f81a9d3b87df7e16c852f2505ac913193ca (diff) | |
download | dabmux-d930ee6b9a52f0eb9939b3fe55afd2361944edb2.tar.gz dabmux-d930ee6b9a52f0eb9939b3fe55afd2361944edb2.tar.bz2 dabmux-d930ee6b9a52f0eb9939b3fe55afd2361944edb2.zip |
add support for ZeroMQ output
Diffstat (limited to 'src/dabOutput/dabOutput.h')
-rw-r--r-- | src/dabOutput/dabOutput.h | 42 |
1 files changed, 42 insertions, 0 deletions
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 <stdexcept> #include <signal.h> #ifdef _WIN32 # include <io.h> @@ -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 |