BlueZero (BØ)
Middleware for distributed applications
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
b0::Publisher Class Reference

The publisher class. More...

#include <b0/publisher.h>

Inheritance diagram for b0::Publisher:
b0::Socket b0::logger::LogInterface

Public Member Functions

 Publisher (Node *node, std::string topic, bool managed=true, bool notify_graph=true)
 Construct an Publisher child of the specified Node.
 
virtual ~Publisher ()
 Publisher destructor.
 
void log (LogLevel level, std::string message) const override
 Log a message using node's logger, prepending this publisher informations.
 
virtual void init () override
 Perform initialization and optionally send graph notify.
 
virtual void cleanup () override
 Perform cleanup and optionally send graph notify.
 
std::string getTopicName ()
 Return the name of this publisher's topic.
 
virtual void publish (const std::string &msg)
 Publish a message.
 
- Public Member Functions inherited from b0::Socket
 Socket (Node *node, int type, std::string name, bool managed=true)
 Construct a Socket.
 
virtual ~Socket ()
 Socket destructor.
 
void setHasHeader (bool has_header)
 Set the has_header_ flag which specifies if this socket require a message part with the address (usually for publish/subscribe pattern).
 
void log (LogLevel level, std::string message) const override
 Log a message to the default logger of this node.
 
virtual void spinOnce ()
 Process incoming messages and call callbacks.
 
void setRemoteAddress (std::string addr)
 Set the remote address the socket will connect to.
 
std::string getName () const
 Return the name of the socket bus.
 
NodegetNode () const
 Return the node owning this socket.
 
bool matchesPattern (const std::string &pattern) const
 Check if this socket name matches the specified pattern. More...
 
virtual void readRaw (std::string &msg)
 Read a raw payload from the underlying ZeroMQ socket.
 
virtual void readRaw (std::string &msg, std::string &type)
 Read a raw payload with type from the underlying ZeroMQ socket.
 
virtual bool poll (long timeout=0)
 Poll for messages. If timeout is 0 return immediately, otherwise wait for the specified amount of milliseconds.
 
virtual void writeRaw (const std::string &msg, const std::string &type="")
 Write a raw payload.
 
void setCompression (std::string algorithm, int level=-1)
 Set compression algorithm and level. More...
 
int getReadTimeout () const
 (low-level socket option) Get read timeout (in milliseconds, -1 for no timeout)
 
void setReadTimeout (int timeout)
 (low-level socket option) Set read timeout (in milliseconds, -1 for no timeout)
 
int getWriteTimeout () const
 (low-level socket option) Get write timeout (in milliseconds, -1 for no timeout)
 
void setWriteTimeout (int timeout)
 (low-level socket option) Set write timeout (in milliseconds, -1 for no timeout)
 
int getLingerPeriod () const
 (low-level socket option) Get linger period (in milliseconds, -1 for no timeout)
 
void setLingerPeriod (int period)
 (low-level socket option) Set linger period (in milliseconds, -1 for no timeout)
 
int getBacklog () const
 (low-level socket option) Get backlog
 
void setBacklog (int backlog)
 (low-level socket option) Set backlog
 
bool getImmediate () const
 (low-level socket option) Get immediate flag
 
void setImmediate (bool immediate)
 (low-level socket option) Set immediate flag
 
bool getConflate () const
 (low-level socket option) Get conflate flag
 
void setConflate (bool conflate)
 (low-level socket option) Set conflate flag
 
int getReadHWM () const
 (low-level socket option) Get read high-water-mark
 
void setReadHWM (int n)
 (low-level socket option) Set read high-water-mark
 
int getWriteHWM () const
 (low-level socket option) Get write high-water-mark
 
void setWriteHWM (int n)
 (low-level socket option) Set write high-water-mark
 
- Public Member Functions inherited from b0::logger::LogInterface
template<typename... Arguments>
void log (LogLevel level, std::string const &fmt, Arguments &&... args) const
 Log a message using a format string.
 

Protected Member Functions

virtual void connect ()
 Connect to the remote address.
 
virtual void disconnect ()
 Disconnect from the remote address.
 
- Protected Member Functions inherited from b0::Socket
void connect (std::string const &addr)
 Wrapper to zmq::socket_t::connect.
 
void disconnect (std::string const &addr)
 Wrapper to zmq::socket_t::disconnect.
 
void bind (std::string const &addr)
 Wrapper to zmq::socket_t::bind.
 
void unbind (std::string const &addr)
 Wrapper to zmq::socket_t::unbind.
 
void setsockopt (int option, const void *optval, size_t optvallen)
 Wrapper to zmq::socket_t::setsockopt.
 
void getsockopt (int option, void *optval, size_t *optvallen) const
 Wrapper to zmq::socket_t::getsockopt.
 
void setIntOption (int option, int value)
 High level wrapper for setsockopt.
 
int getIntOption (int option) const
 High level wrapper for getsockopt.
 

Protected Attributes

const bool notify_graph_
 If false this socket will not send announcement to resolv (i.e. it will be "invisible")
 
- Protected Attributes inherited from b0::Socket
Nodenode_
 The Node owning this Socket.
 
std::string name_
 This socket bus name.
 
bool has_header_
 True if the payload has a header part (i.e. More...
 
const bool managed_
 True if this socket is managed (init(), cleanup() are called by the owner Node)
 
std::string remote_addr_
 The address of the ZeroMQ socket to connect to (will skip name resolution if given)
 

Additional Inherited Members

- Public Types inherited from b0::logger::LogInterface
enum  LogLevel {
  trace = 0, debug = 10, info = 20, warn = 30,
  error = 40, fatal = 50
}
 

Detailed Description

The publisher class.

This class wraps a PUB socket. It will automatically connect to the XSUB socket of the proxy (note: the proxy is started by the resolver node).

See also
b0::Publisher, b0::Subscriber
Examples:
multi_publisher.cpp, publisher_node.cpp, and publisher_node_object.cpp.

The documentation for this class was generated from the following file: