GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
pub_sink.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013,2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio.
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_ZEROMQ_PUB_SINK_H
12 #define INCLUDED_ZEROMQ_PUB_SINK_H
13 
14 #include <gnuradio/sync_block.h>
15 #include <gnuradio/zeromq/api.h>
16 
17 namespace gr {
18 namespace zeromq {
19 
20 /*!
21  * \brief Sink the contents of a stream to a ZMQ PUB socket
22  * \ingroup zeromq
23  *
24  * \details
25  * This block acts as a streaming sink for a GNU Radio flowgraph
26  * and writes its contents to a ZMQ PUB socket. A PUB socket may
27  * have subscribers and will pass all incoming stream data to each
28  * subscriber with a matching key. If the publisher's key is set to
29  * "GNURadio", the following example subscriber keys will match: "G",
30  * "GN", .., "GNURadio". In other words, the subscriber must contain
31  * the first set of characters from the publisher's key. If the subscriber
32  * sets an empty key "", it will accept all input messages from the
33  * publisher (including the key itself if one is set). Subscribers
34  * can either be another gr-zeromq source block or a non-GNU Radio
35  * ZMQ socket.
36  */
37 class ZEROMQ_API pub_sink : virtual public gr::sync_block
38 {
39 public:
40  typedef std::shared_ptr<pub_sink> sptr;
41 
42  /*!
43  * \brief Return a shared_ptr to a new instance of zeromq::pub_sink.
44  *
45  * \param itemsize Size of a stream item in bytes.
46  * \param vlen Vector length of the input items. Note that one vector is one item.
47  * \param address ZMQ socket address specifier.
48  * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments.
49  * \param pass_tags Whether sink will serialize and pass tags over the link.
50  * \param hwm High Watermark to configure the socket to (-1 => zmq's default)
51  * \param key Prepend a key/topic to the start of each message (default is none)
52  */
53  static sptr make(size_t itemsize,
54  size_t vlen,
55  char* address,
56  int timeout = 100,
57  bool pass_tags = false,
58  int hwm = -1,
59  const std::string& key = "");
60 
61  /*!
62  * \brief Return a std::string of ZMQ_LAST_ENDPOINT from the underlying ZMQ socket.
63  */
64  virtual std::string last_endpoint() = 0;
65 };
66 
67 } // namespace zeromq
68 } // namespace gr
69 
70 #endif /* INCLUDED_ZEROMQ_PUB_SINK_H */
synchronous 1:1 input to output with history
Definition: sync_block.h:26
Sink the contents of a stream to a ZMQ PUB socket.
Definition: pub_sink.h:38
static sptr make(size_t itemsize, size_t vlen, char *address, int timeout=100, bool pass_tags=false, int hwm=-1, const std::string &key="")
Return a shared_ptr to a new instance of zeromq::pub_sink.
std::shared_ptr< pub_sink > sptr
Definition: pub_sink.h:40
virtual std::string last_endpoint()=0
Return a std::string of ZMQ_LAST_ENDPOINT from the underlying ZMQ socket.
#define ZEROMQ_API
Definition: gr-zeromq/include/gnuradio/zeromq/api.h:18
BLOCKS_API size_t itemsize(vector_type type)
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29