Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
zmqpp_compat.hpp File Reference

Opt-in zmqpp-shaped API over cppzmq, for downstream code only. More...

#include <cstring>
#include <string>
#include <utility>
#include <zmq.hpp>
#include <zmq_addon.hpp>
#include "zap_auth.hpp"

Go to the source code of this file.

Namespaces

namespace  zmqpp
 Minimal stand-in for the parts of zmqpp that MADS used to expose.
 
namespace  zmqpp::socket_option
 Socket option names, mapped onto the type-checked zmq::sockopt.
 
namespace  zmqpp::curve
 zmqpp-shaped context: a zmq::context_t plus terminate().
 

Macros

#define MADS_ZMQPP_DEPRECATED(msg)   [[deprecated(msg)]]
 

Typedefs

using zmqpp::socket_type = zmq::socket_type
 Socket types, spelled as in zmqpp (socket_type::pub, ...).
 
using zmqpp::exception = zmq::error_t
 zmqpp's single exception type maps onto cppzmq's.
 
using zmqpp::zmq_internal_exception = zmq::error_t
 zmqpp raised this for libzmq-level failures; cppzmq has one type.
 
using zmqpp::curve::keypair = Mads::CurveKeypair
 zmqpp's keypair struct; the fields keep their names.
 

Functions

keypair zmqpp::curve::generate_keypair ()
 Generate a CURVE keypair.
 

Variables

constexpr auto zmqpp::socket_option::linger = zmq::sockopt::linger
 
constexpr auto zmqpp::socket_option::receive_timeout = zmq::sockopt::rcvtimeo
 
constexpr auto zmqpp::socket_option::send_timeout = zmq::sockopt::sndtimeo
 
constexpr auto zmqpp::socket_option::conflate = zmq::sockopt::conflate
 
constexpr auto zmqpp::socket_option::receive_high_water_mark = zmq::sockopt::rcvhwm
 
constexpr auto zmqpp::socket_option::send_high_water_mark = zmq::sockopt::sndhwm
 
constexpr auto zmqpp::socket_option::identity = zmq::sockopt::routing_id
 
constexpr auto zmqpp::socket_option::curve_server = zmq::sockopt::curve_server
 
constexpr auto zmqpp::socket_option::curve_public_key = zmq::sockopt::curve_publickey
 
constexpr auto zmqpp::socket_option::curve_secret_key = zmq::sockopt::curve_secretkey
 
constexpr auto zmqpp::socket_option::curve_server_key = zmq::sockopt::curve_serverkey
 

Detailed Description

Opt-in zmqpp-shaped API over cppzmq, for downstream code only.

MADS used to expose zmqpp types on Mads::Agent's protected interface (_context, _publisher, _subscriber, receive_raw()) and pulled <zmqpp/zmqpp.hpp> in transitively through agent.hpp. Since the cppzmq migration those members are zmq::context_t / zmq::socket_t / zmq::multipart_t and no MADS header includes zmqpp at all.

A downstream agent that only calls the public API (publish(), receive(), loop(), settings, callbacks) — and every consumer of Mads::AgentApp, whose interface never named a ZMQ type — needs nothing from this header. It exists for the narrower case of a subclass that touches the sockets directly, e.g.

#include <agent.hpp>
#include <zmqpp_compat.hpp> // <-- add this one line
class MyAgent : public Mads::Agent {
void send_side_channel() {
zmqpp::socket s(_context, zmqpp::socket_type::push); // still compiles
s.connect("tcp://localhost:9099");
zmqpp::message m;
m << "hello";
s.send(m);
}
};
Opt-in zmqpp-shaped API over cppzmq, for downstream code only.

The types here derive from their cppzmq counterparts rather than wrapping them, so a zmqpp::socket still binds to a zmq::socket_t& parameter (Mads::CurveAuth::setup_curve_client(), for one) and the Agent members bind to zmqpp::socket& parameters in downstream code.

Warning
Deprecated on arrival: it covers only the API surface MADS itself used, and it will be removed in the release after next. Port to the cppzmq types directly. Note also that this is a source compatibility aid only: MadsCore is a shared library whose class layout changed, so downstream code must be recompiled regardless.

Define MADS_NO_ZMQPP_COMPAT_WARNING before including to silence the deprecation warnings while porting.

Definition in file zmqpp_compat.hpp.

Macro Definition Documentation

◆ MADS_ZMQPP_DEPRECATED

#define MADS_ZMQPP_DEPRECATED (   msg)    [[deprecated(msg)]]

Definition at line 81 of file zmqpp_compat.hpp.