Belle II Software light-2406-ragdoll
ZMQIdMessage.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/messages/ZMQModuleMessage.h>
11#include <framework/pcore/zmq/messages/ZMQDefinitions.h>
12
13#include <zmq.hpp>
14
15namespace Belle2 {
21 class ZMQIdMessage : public ZMQModuleMessage<4> {
22 friend class ZMQMessageFactory;
23
24 public:
26 static constexpr const unsigned int c_identity = 0;
28 static constexpr const unsigned int c_type = 1;
30 static constexpr const unsigned int c_data = 2;
32 static constexpr const unsigned int c_additionalData = 3;
33
35 bool isMessage(const EMessageTypes isType) const
36 {
37 const auto& type = getMessagePartAsString<c_type>();
38 return type.size() == 1 and type[0] == static_cast<char>(isType);
39 }
40
42 std::string getIdentity() const
43 {
44 return getMessagePartAsString<c_identity>();
45 }
46
48 zmq::message_t& getDataMessage()
49 {
50 return getMessagePart<c_data>();
51 }
52
54 zmq::message_t& getAdditionalDataMessage()
55 {
56 return getMessagePart<c_additionalData>();
57 }
58
59 private:
62 };
64}
A message with the socket ID. Needed in input<->worker communication.
Definition: ZMQIdMessage.h:21
bool isMessage(const EMessageTypes isType) const
The if the message is of a given type.
Definition: ZMQIdMessage.h:35
std::string getIdentity() const
Get the identity part.
Definition: ZMQIdMessage.h:42
static constexpr const unsigned int c_additionalData
Where the additional data is stored.
Definition: ZMQIdMessage.h:32
zmq::message_t & getDataMessage()
Get the data part.
Definition: ZMQIdMessage.h:48
static constexpr const unsigned int c_data
Where the data is stored.
Definition: ZMQIdMessage.h:30
static constexpr const unsigned int c_identity
Where the identity is stored.
Definition: ZMQIdMessage.h:26
static constexpr const unsigned int c_type
Where the type of the message is stored.
Definition: ZMQIdMessage.h:28
zmq::message_t & getAdditionalDataMessage()
Get the additional data part.
Definition: ZMQIdMessage.h:54
Helper class for creating new ID/No-ID messages.
A general message with as many parts as given as template argument.
ZMQModuleMessage()=default
Do not allow to create a new message from scratch publicly.
EMessageTypes
Type the messages can have.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24