10#include <framework/pcore/zmq/messages/ZMQMessageHelper.h>
23 template <
unsigned int AMessageFrameNumber>
32 using MessageParts = std::array<zmq::message_t, ZMQModuleMessage::c_messageParts>;
35 static void toSocket(std::unique_ptr<ZMQModuleMessage> message,
const std::unique_ptr<zmq::socket_t>& socket)
38 socket->send(message->m_messageParts[i], zmq::send_flags::sndmore);
40 socket->send(message->m_messageParts[
c_messageParts - 1], zmq::send_flags::none);
61 template <
unsigned int index>
68 template <
unsigned int index>
71 const auto& messagePart = getMessagePart<index>();
72 return static_cast<const char*
>(messagePart.data());
76 template <
unsigned int index>
79 const auto& messagePart = getMessagePart<index>();
80 return std::string(
static_cast<const char*
>(messagePart.data()), messagePart.size());
84 template <
unsigned int index>
91 template <
unsigned int index>
94 auto& messagePart = getMessagePart<index>();
95 return static_cast<char*
>(messagePart.data());
103 template <
class ...T>
Helper class for creating new ID/No-ID messages.
static zmq::message_t createZMQMessage(zmq::message_t message)
Just pass a zmq message.
A general message with as many parts as given as template argument.
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.
const char * getMessagePartAsCharArray() const
Get the message part with the given index as char* (const version)
const zmq::message_t & getMessagePart() const
Get the message part with the given index (const version)
zmq::message_t & getMessagePart()
Get the message part with the given index.
void operator=(const ZMQModuleMessage &)=delete
Do not allow to copy a message.
ZMQModuleMessage(const ZMQModuleMessage &)=delete
Do not allow to copy a message.
const MessageParts & getMessageParts() const
Get a const reference to the message parts.
ZMQModuleMessage()=default
Do not allow to create a new message from scratch publicly.
static constexpr unsigned int c_messageParts
The number of message parts this message carries.
std::string getMessagePartAsString() const
Get the message part with the given index as string (const version)
MessageParts m_messageParts
The content of this message as an array of zmq messages. Will be set during constructor or when comin...
char * getMessagePartAsCharArray()
Get the message part with the given index as char*.
std::array< zmq::message_t, ZMQModuleMessage::c_messageParts > MessageParts
The base class of the message parts.
ZMQModuleMessage(T &&... arguments)
Constructor out of different parts.
MessageParts & getMessageParts()
Get a reference to the message parts.
Abstract base class for different kinds of events.