Belle II Software development
ZMQROIConnection.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <framework/pcore/zmq/connections/ZMQRawConnection.h>
11#include <framework/pcore/zmq/utils/ZMQParent.h>
12#include <framework/pcore/zmq/messages/ZMQNoIdMessage.h>
13
14#include <zmq.hpp>
15
16namespace Belle2 {
21
29 class ZMQROIOutput : public ZMQConnection {
30 public:
32 ZMQROIOutput(const std::string& outputAddress, const std::shared_ptr<ZMQParent>& parent);
33
35 void handleEvent(zmq::message_t message);
37 std::string getMonitoringJSON() const final;
41 bool isReady() const final;
43 std::vector<zmq::socket_t*> getSockets() const final;
45 std::string getEndPoint() const { return m_rawOutput.getEndPoint(); }
46 private:
47
50
52 void addHeader(char* buffer, unsigned int size);
54 void addTrailer(char* buffer);
55 };
56
66 public:
68 ZMQDataAndROIOutput(const std::string& dataAddress, const std::string& roiAddress, bool addEventSize,
69 const std::shared_ptr<ZMQParent>& parent);
70
72 std::string getMonitoringJSON() const final;
74 std::string getROIMonitoringJSON() const;
75
77 void handleEvent(std::unique_ptr<ZMQNoIdMessage> message);
79 void handleIncomingData();
81 bool isReady() const final;
83 std::vector<zmq::socket_t*> getSockets() const final;
85 std::string getEndPoint() const { return m_dataOutput.getEndPoint() + ";" + m_roiOutput.getEndPoint(); }
86 private:
91 };
92
93}
Base class for every connection with virtual functions to be implemented:
std::string getEndPoint() const
Return the connection string.
void handleIncomingData()
Handle both a socket (dis)connect by raw or ROI.
ZMQRawOutput m_dataOutput
The used raw connection.
std::string getROIMonitoringJSON() const
Get the monitoring JSON from the ROI connection.
bool isReady() const final
Ready only when both sockets are ready.
std::string getMonitoringJSON() const final
Get the monitoring JSON from the raw connection.
ZMQRawOutput m_roiOutput
The used ROI connection.
void handleEvent(std::unique_ptr< ZMQNoIdMessage > message)
Send the normal data message to raw and the additional message to ROI.
std::vector< zmq::socket_t * > getSockets() const final
Return both sockets for polling.
ZMQDataAndROIOutput(const std::string &dataAddress, const std::string &roiAddress, bool addEventSize, const std::shared_ptr< ZMQParent > &parent)
Initialize the raw and roi connection.
void addTrailer(char *buffer)
Helper function to add the trailer.
std::string getEndPoint() const
Return the connection string.
void handleIncomingData()
Copy the functionality from the raw output.
ZMQROIOutput(const std::string &outputAddress, const std::shared_ptr< ZMQParent > &parent)
Create a new ROI output basically initializing the raw output member.
void handleEvent(zmq::message_t message)
Send a message and add the PXD specific header and trailer.
void addHeader(char *buffer, unsigned int size)
Helper function to add the header with the given message size.
bool isReady() const final
Copy the functionality from the raw output.
std::string getMonitoringJSON() const final
Copy the functionality from the raw output.
std::vector< zmq::socket_t * > getSockets() const final
Copy the functionality from the raw output.
ZMQRawOutput m_rawOutput
The used raw output.
Output connection to speak to non-zmq sockets via a ZMQ_STREAM socket.
Abstract base class for different kinds of events.
STL namespace.