8 #ifndef OCM_DAQ_DAQ_EVENT_HPP_
9 #define OCM_DAQ_DAQ_EVENT_HPP_
17 #include <boost/signals2/signal.hpp>
30 using TimePoint = std::chrono::time_point<std::chrono::steady_clock>;
66 using ActionEvent::ActionEvent;
72 std::optional<Status>
status,
73 std::string
origin) noexcept;
90 using EventType = std::variant<ActionEvent, UserActionEvent, GenericEvent, ErrorEvent>;
91 using TimePoint = std::chrono::time_point<std::chrono::steady_clock>;
133 template<
class T,
class... Args>
135 m_event_log.
events.emplace_back(std::in_place_type<T>, std::forward<Args>(args)...);
136 m_signal(m_event_log.
events.back());
153 template <
class Observer>
155 return m_signal.connect(std::move(o));
173 return m_event_log.
events;
Stores data acquisition status and allows subscription to status changes.
void EmplaceEvent(Args &&... args)
Like AddEvent but emplaces the specified event type.
boost::signals2::connection ConnectObserver(Observer o)
Connect observer that is invoked when state is modified.
ObservableEventLog(ObservableEventLog const &)=delete
ObservableEventLog & operator=(ObservableEventLog const &)=delete
void AddEvent(EventLog::EventType event)
Records that a file has been produced for this data acquisition.
EventLog const & GetEventLog() const noexcept
Allow implicit conversion to non-observable status.
std::vector< EventLog::EventType > const & GetEventContainer() const noexcept
Allow implicit conversion to non-observable status.
ObservableEventLog()=default
Construct a new object.
boost::signals2::signal< void(EventLog::EventType const &)> Signal
daqif::DaqStatus & operator<<(daqif::DaqStatus &status, daq::Status const &rhs)
Convert daq::Status -> daqif::DaqStatus by populating from rhs.
Contains declaration for Status and ObservableStatus.
Event related to an action being requested or performed.
ErrorEvent(std::string id, std::string description, std::optional< Status > status, std::string origin) noexcept
bool operator!=(ErrorEvent const &rhs) const noexcept
std::string origin
Error origin.
bool operator==(ErrorEvent const &rhs) const noexcept
Represents a collection of events.
std::variant< ActionEvent, UserActionEvent, GenericEvent, ErrorEvent > EventType
bool operator!=(EventLog const &rhs) const noexcept
std::vector< EventType > events
bool operator==(EventLog const &rhs) const noexcept
std::chrono::time_point< std::chrono::steady_clock > TimePoint
Represents a generic event if a more specific event is not usable.
bool operator!=(GenericEvent const &rhs) const noexcept
GenericEvent(GenericEvent &&)=default
GenericEvent & operator=(GenericEvent const &)=default
GenericEvent & operator=(GenericEvent &&)=default
std::chrono::time_point< std::chrono::steady_clock > TimePoint
GenericEvent(GenericEvent const &)=default
std::optional< Status > status
GenericEvent(std::string id, std::string description, std::optional< Status > status) noexcept
bool operator==(GenericEvent const &rhs) const noexcept
Event directly related to user action, such as a command to do something.