 |
Belle II Software
release-05-02-19
|
12 #include <framework/pcore/zmq/messages/ZMQMessageHelper.h>
24 template <
unsigned int AMessageFrameNumber>
26 class ZMQModuleMessage {
27 friend class ZMQMessageFactory;
31 static constexpr
unsigned int c_messageParts = AMessageFrameNumber;
34 using MessageParts = std::array<zmq::message_t, ZMQModuleMessage::c_messageParts>;
37 static void toSocket(std::unique_ptr<ZMQModuleMessage> message,
const std::unique_ptr<zmq::socket_t>& socket)
40 socket->send(message->m_messageParts[i], ZMQ_SNDMORE);
63 template <
unsigned int index>
70 template <
unsigned int index>
73 const auto& messagePart = getMessagePart<index>();
74 return static_cast<const char*
>(messagePart.data());
78 template <
unsigned int index>
81 const auto& messagePart = getMessagePart<index>();
82 return std::string(
static_cast<const char*
>(messagePart.data()), messagePart.size());
86 template <
unsigned int index>
93 template <
unsigned int index>
96 auto& messagePart = getMessagePart<index>();
97 return static_cast<char*
>(messagePart.data());
105 template <
class ...T>
static constexpr unsigned int c_messageParts
The number of message parts this message carries.
const char * getMessagePartAsCharArray() const
Get the message part with the given index as char* (const version)
MessageParts & getMessageParts()
Get a reference to the message parts.
static zmq::message_t createZMQMessage(zmq::message_t message)
Just pass a zmq message.
ZMQModuleMessage()=default
Do not allow to create a new message from scratch publicly.
std::string getMessagePartAsString() const
Get the message part with the given index as string (const version)
static void toSocket(std::unique_ptr< ZMQModuleMessage > message, const std::unique_ptr< zmq::socket_t > &socket)
Send the message to the given socket. As the message is nullified, you have to move it in here.
A general message with as many parts as given as template argument.
Abstract base class for different kinds of events.
const zmq::message_t & getMessagePart() const
Get the message part with the given index (const version)
std::array< zmq::message_t, ZMQModuleMessage::c_messageParts > MessageParts
The base class of the message parts.
void operator=(const ZMQModuleMessage &)=delete
Do not allow to copy a message.
MessageParts m_messageParts
The content of this message as an array of zmq messages. Will be set during constructor or when comin...