ifw-daq  3.0.0-pre2
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 #include <iostream>
11 
12 namespace daq {
13 
15  std::string description,
16  std::optional<Status> status) noexcept
17  : timestamp(TimePoint::clock::now()), id(std::move(id)), description(std::move(description)), status(std::move(status)) {
18 }
19 
20 bool GenericEvent::operator==(GenericEvent const& rhs) const noexcept {
21  return id == rhs.id && description == rhs.description && status == rhs.status;
22 }
23 
24 bool GenericEvent::operator!=(GenericEvent const& rhs) const noexcept {
25  return !(*this == rhs);
26 }
27 
28 ErrorEvent::ErrorEvent(std::string id,
29  std::string description,
30  std::optional<Status> status,
31  std::string origin) noexcept
32  : GenericEvent(std::move(id), std::move(description), std::move(status))
33  , origin(std::move(origin)) {
34 }
35 
36 bool ErrorEvent::operator==(ErrorEvent const& rhs) const noexcept {
37  return GenericEvent::operator==(rhs) && origin == rhs.origin;
38 }
39 
40 bool ErrorEvent::operator!=(ErrorEvent const& rhs) const noexcept {
41  return !(*this == rhs);
42 }
43 
44 std::ostream& operator<<(std::ostream& os, GenericEvent const& s) {
45  os << "ErrorEvent(id='" << s.id << "', description=" << s.description
46  << ")";
47  return os;
48 }
49 
50 std::ostream& operator<<(std::ostream& os, ErrorEvent const& s) {
51  os << "ErrorEvent(id='" << s.id << "', origin=" << s.origin << ", description=" << s.description
52  << ")";
53  return os;
54 }
55 
57  m_signal(event);
58  m_event_log.events.emplace_back(std::move(event));
59 }
60 
61 } // namespace daq
void AddEvent(EventLog::EventType event)
Records that a file has been produced for this data acquisition.
Definition: eventLog.cpp:56
Contains declaration for EventLog, ObservableEventLog and related events.
daqif::DaqStatus & operator<<(daqif::DaqStatus &status, daq::Status const &rhs)
Convert daq::Status -> daqif::DaqStatus by populating from rhs.
Definition: conversion.cpp:18
ErrorEvent(std::string id, std::string description, std::optional< Status > status, std::string origin) noexcept
Definition: eventLog.cpp:28
bool operator!=(ErrorEvent const &rhs) const noexcept
Definition: eventLog.cpp:40
std::string origin
Error origin.
Definition: eventLog.hpp:79
bool operator==(ErrorEvent const &rhs) const noexcept
Definition: eventLog.cpp:36
std::variant< ActionEvent, UserActionEvent, GenericEvent, ErrorEvent > EventType
Definition: eventLog.hpp:90
std::vector< EventType > events
Definition: eventLog.hpp:96
Represents a generic event if a more specific event is not usable.
Definition: eventLog.hpp:29
bool operator!=(GenericEvent const &rhs) const noexcept
Definition: eventLog.cpp:24
std::string description
Definition: eventLog.hpp:44
GenericEvent(std::string id, std::string description, std::optional< Status > status) noexcept
Definition: eventLog.cpp:14
bool operator==(GenericEvent const &rhs) const noexcept
Definition: eventLog.cpp:20
std::string id
Definition: eventLog.hpp:43