Belle II Software  release-05-01-25
ZMQIdMessage.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun, Anselm Baur *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/pcore/zmq/messages/ZMQModuleMessage.h>
13 #include <framework/pcore/zmq/messages/ZMQDefinitions.h>
14 
15 #include <zmq.hpp>
16 
17 namespace Belle2 {
22  class ZMQIdMessage : public ZMQModuleMessage<4> {
24  friend class ZMQMessageFactory;
25 
26  public:
28  static constexpr const unsigned int c_identity = 0;
30  static constexpr const unsigned int c_type = 1;
32  static constexpr const unsigned int c_data = 2;
34  static constexpr const unsigned int c_additionalData = 3;
35 
37  bool isMessage(const EMessageTypes isType) const
38  {
39  const auto& type = getMessagePartAsString<c_type>();
40  return type.size() == 1 and type[0] == static_cast<char>(isType);
41  }
42 
44  std::string getIdentity() const
45  {
46  return getMessagePartAsString<c_identity>();
47  }
48 
50  zmq::message_t& getDataMessage()
51  {
52  return getMessagePart<c_data>();
53  }
54 
56  zmq::message_t& getAdditionalDataMessage()
57  {
58  return getMessagePart<c_additionalData>();
59  }
60 
61  private:
64  };
66 }
Belle2::ZMQIdMessage::getIdentity
std::string getIdentity() const
Get the identity part.
Definition: ZMQIdMessage.h:52
Belle2::ZMQIdMessage::c_data
static constexpr const unsigned int c_data
Where the data is stored.
Definition: ZMQIdMessage.h:40
Belle2::EMessageTypes
EMessageTypes
Type the messages can have.
Definition: ZMQDefinitions.h:26
Belle2::ZMQIdMessage::getDataMessage
zmq::message_t & getDataMessage()
Get the data part.
Definition: ZMQIdMessage.h:58
Belle2::ZMQModuleMessage::ZMQModuleMessage
ZMQModuleMessage()=default
Do not allow to create a new message from scratch publicly.
Belle2::ZMQIdMessage::c_type
static constexpr const unsigned int c_type
Where the type of the message is stored.
Definition: ZMQIdMessage.h:38
Belle2::ZMQIdMessage::c_identity
static constexpr const unsigned int c_identity
Where the identity is stored.
Definition: ZMQIdMessage.h:36
Belle2::ZMQIdMessage::getAdditionalDataMessage
zmq::message_t & getAdditionalDataMessage()
Get the additional data part.
Definition: ZMQIdMessage.h:64
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ZMQIdMessage::c_additionalData
static constexpr const unsigned int c_additionalData
Where the additional data is stored.
Definition: ZMQIdMessage.h:42
Belle2::ZMQIdMessage::isMessage
bool isMessage(const EMessageTypes isType) const
The if the message is of a given type.
Definition: ZMQIdMessage.h:45