 |
Belle II Software
release-05-01-25
|
12 #include <framework/pcore/zmq/utils/ZMQLogger.h>
13 #include <framework/pcore/zmq/utils/ZMQParent.h>
32 class ZMQConnection :
public ZMQLogger {
46 static bool poll(
const std::map<const ZMQConnection*, ReactorFunction>& connectionList,
int timeout);
49 static bool hasMessage(
const ZMQConnection* connection);
57 virtual std::vector<zmq::socket_t*>
getSockets()
const = 0;
64 class ZMQConnectionOverSocket :
public ZMQConnection {
70 std::vector<zmq::socket_t*>
getSockets() const final;
76 std::unique_ptr<zmq::socket_t>
m_socket;
std::shared_ptr< ZMQParent > m_parent
The shared ZMQParent instance.
std::function< void(void)> ReactorFunction
Typedef of a function which will be called if a connection has a message.
virtual ~ZMQConnection()=default
Virtual default destructor.
virtual bool isReady() const
Return true of this connection is able to send messages right now. Can be overloaded in derived class...
Abstract base class for different kinds of events.
virtual std::vector< zmq::socket_t * > getSockets() const =0
Return the list of sockets which should be polled on to check for incoming messages....
static bool poll(const std::map< const ZMQConnection *, ReactorFunction > &connectionList, int timeout)
Poll on the given connections and call the attached function if a messages comes in.
A helper class for creating ZMQ sockets keeping track of the ZMQ context and terminating it if needed...
ZMQConnectionOverSocket(const std::shared_ptr< ZMQParent > &parent)
Create a new instance passing the shared ZMQParent.
static bool hasMessage(const ZMQConnection *connection)
Check if the given connection as an incoming message (right now, no waiting).
std::unique_ptr< zmq::socket_t > m_socket
The memory of the socket. Needs to be initialized in a derived class.
std::vector< zmq::socket_t * > getSockets() const final
The socket used for polling is just the stored socket.