Belle II Software light-2406-ragdoll
ProcessedEventBackup.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/dataobjects/EventMetaData.h>
11#include <framework/pcore/EvtMessage.h>
12#include <framework/pcore/zmq/messages/ZMQMessageFactory.h>
13#include <memory>
14#include <chrono>
15
16namespace Belle2 {
24 using TimeStamp = std::chrono::time_point<std::chrono::system_clock>;
25 public:
27 ProcessedEventBackup(std::unique_ptr<EvtMessage> evtMsg, const EventMetaData& evtMetaData,
28 unsigned int workerId);
29
31 bool operator==(const EventMetaData& rhs);
32
34 template <class AZMQClient>
35 void sendToSocket(const AZMQClient& socket);
36
38 const EventMetaData& getEventMetaData() const;
40 const TimeStamp& getTimestamp() const;
42 const unsigned int& getWorkerId() const;
43
44 private:
46 std::unique_ptr<EvtMessage> m_eventMessage;
50 unsigned int m_workerId;
52 TimeStamp m_timestamp = std::chrono::system_clock::now();
53 };
54
55 template <class AZMQClient>
56 void ProcessedEventBackup::sendToSocket(const AZMQClient& socket)
57 {
58 auto message = ZMQMessageFactory::createMessage(EMessageTypes::c_eventMessage, m_eventMessage);
59 socket.publish(std::move(message));
60 B2DEBUG(100, "sent backup evt: " << m_eventMetaData.getEvent());
61 }
63}
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
unsigned int getEvent() const
Event Getter.
Storage item for the event backup storing the event message, the time stamp and the event meta data.
const TimeStamp & getTimestamp() const
Getter for the stored time stamp.
std::chrono::time_point< std::chrono::system_clock > TimeStamp
Short for the class of the time stamp (it is a system clock time stamp)
const unsigned int & getWorkerId() const
Getter for the stored worker id.
TimeStamp m_timestamp
Getter for the stored time stamp.
unsigned int m_workerId
Getter for the stored worker id.
const EventMetaData & getEventMetaData() const
Getter for the stored event meta data.
bool operator==(const EventMetaData &rhs)
Compare operator needed in the backup list.
EventMetaData m_eventMetaData
Getter for the stored event meta data.
std::unique_ptr< EvtMessage > m_eventMessage
Stored event message.
static auto createMessage(const std::string &msgIdentity, const EMessageTypes msgType, const std::unique_ptr< EvtMessage > &eventMessage)
Create an ID Message out of an identity, the type and an event message.
void sendToSocket(const AZMQClient &socket)
Publish this event backup directly to the given client.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24