ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
eventLog.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_common_libdaq
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Contains definitions for EventLog, ObservableEventLog and related events.
7  */
8 #include <daq/eventLog.hpp>
9 
10 namespace daq {
11 
13  std::string description,
14  std::optional<Status> status) noexcept
15  : timestamp(TimePoint::clock::now()), id(std::move(id)), description(std::move(description)), status(std::move(status)) {
16 }
17 
18 bool GenericEvent::operator==(GenericEvent const& rhs) const noexcept {
19  return id == rhs.id && description == rhs.description && status == rhs.status;
20 }
21 
22 bool GenericEvent::operator!=(GenericEvent const& rhs) const noexcept {
23  return !(*this == rhs);
24 }
25 
26 ErrorEvent::ErrorEvent(std::string id,
27  std::string description,
28  std::optional<Status> status,
29  std::string origin) noexcept
30  : GenericEvent(std::move(id), std::move(description), std::move(status))
31  , origin(std::move(origin)) {
32 }
33 
34 bool ErrorEvent::operator==(ErrorEvent const& rhs) const noexcept {
35  return GenericEvent::operator==(rhs) && origin == rhs.origin;
36 }
37 
38 bool ErrorEvent::operator!=(ErrorEvent const& rhs) const noexcept {
39  return !(*this == rhs);
40 }
41 
42 std::ostream& operator<<(std::ostream& os, GenericEvent const& s) {
43  os << "ErrorEvent(id='" << s.id << "', description=" << s.description
44  << ")";
45  return os;
46 }
47 
48 std::ostream& operator<<(std::ostream& os, ErrorEvent const& s) {
49  os << "ErrorEvent(id='" << s.id << "', origin=" << s.origin << ", description=" << s.description
50  << ")";
51  return os;
52 }
53 
55  m_signal(event);
56  m_event_log.events.emplace_back(std::move(event));
57 }
58 
59 } // namespace daq
daq::ErrorEvent::operator==
bool operator==(ErrorEvent const &rhs) const noexcept
Definition: eventLog.cpp:34
daq::GenericEvent::GenericEvent
GenericEvent(std::string id, std::string description, std::optional< Status > status) noexcept
Definition: eventLog.cpp:12
daq::ErrorEvent::operator!=
bool operator!=(ErrorEvent const &rhs) const noexcept
Definition: eventLog.cpp:38
daq::ErrorEvent
Definition: eventLog.hpp:69
daq
Definition: asyncProcess.cpp:15
eventLog.hpp
Contains declaration for EventLog, ObservableEventLog and related events.
daq::operator<<
daqif::DaqStatus & operator<<(daqif::DaqStatus &status, daq::Status const &rhs)
Convert daq::Status -> daqif::DaqStatus by populating from rhs.
Definition: conversion.cpp:18
daq::EventLog::events
std::vector< EventType > events
Definition: eventLog.hpp:96
daq::GenericEvent::id
std::string id
Definition: eventLog.hpp:43
daq::ErrorEvent::ErrorEvent
ErrorEvent(std::string id, std::string description, std::optional< Status > status, std::string origin) noexcept
Definition: eventLog.cpp:26
daq::GenericEvent::operator!=
bool operator!=(GenericEvent const &rhs) const noexcept
Definition: eventLog.cpp:22
daq::GenericEvent::description
std::string description
Definition: eventLog.hpp:44
daq::ErrorEvent::origin
std::string origin
Error origin.
Definition: eventLog.hpp:79
daq::GenericEvent::operator==
bool operator==(GenericEvent const &rhs) const noexcept
Definition: eventLog.cpp:18
daq::EventLog::EventType
std::variant< ActionEvent, UserActionEvent, GenericEvent, ErrorEvent > EventType
Definition: eventLog.hpp:90
daq::GenericEvent
Represents a generic event if a more specific event is not usable.
Definition: eventLog.hpp:29
daq::ObservableEventLog::AddEvent
void AddEvent(EventLog::EventType event)
Records that a file has been produced for this data acquisition.
Definition: eventLog.cpp:54