RTC Toolkit 4.0.1
Loading...
Searching...
No Matches
alertService.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_COMPONENTFRAMEWORK_ALERTSERVICE_HPP
13#define RTCTK_COMPONENTFRAMEWORK_ALERTSERVICE_HPP
14
15#include <log4cplus/logger.h>
16
20
22
30public:
35 explicit AlertService(log4cplus::Logger logger);
39 ~AlertService() noexcept;
40
41 boost::signals2::connection ConnectReducedStatus(ReducedStatusSignal::slot_type slot) override;
42
43 [[nodiscard]] AlertSource MakeAlertSource(AlertDescription const& description) override;
44
45 [[nodiscard]] ReducedStatus GetReducedStatus() const override;
46 [[nodiscard]] std::vector<AlertStatus> GetAlertStatuses() const override;
47
48private:
54 struct Shadow {
55 AlertStatus status;
56 boost::signals2::connection connection;
57 };
58
64 void UpdateAlertStatus(std::string const& id, bool status, AlertSource::TimePoint since);
65
66 void CollectGarbage();
67
71 mutable std::recursive_mutex m_api_mtx;
72
76 std::vector<Shadow> m_shadow = {};
77 ReducedStatus m_reduced = false;
78 ReducedStatusSignal m_reduced_signal;
79
80 log4cplus::Logger m_logger;
81};
82
90public:
91 AlertLogger(log4cplus::Logger logger, AlertServiceIf& service);
92
93private:
94 void Slot(AlertServiceIf::ReducedStatus const& status,
95 std::vector<AlertServiceIf::AlertStatus> const& active);
96 log4cplus::Logger m_logger;
97 boost::signals2::scoped_connection m_connection;
98};
99
107public:
116 AlertEventPublisher(std::string name,
117 AlertStatusObserverIf& alert_service,
118 EventServiceIf& event_service,
119 log4cplus::Logger logger);
120
121private:
125 void Slot(AlertServiceIf::ReducedStatus const& status,
126 std::vector<AlertStatusObserverIf::AlertStatus> const& active);
127
128 std::string m_name;
129 TypedEventService m_event_service;
130 log4cplus::Logger m_logger;
131 boost::signals2::scoped_connection m_connection;
132
133 std::unique_ptr<TypedEventPublisher<AlertStatusEvent>> m_publisher;
134};
135
136} // namespace rtctk::componentFramework
137
138#endif // RTCTK_COMPONENTFRAMEWORK_ALERTSERVICE_HPP
Header file for AlertServiceIf and related classes.
Uniquely describes an alert.
Definition: alertServiceIf.hpp:152
Alert observer that publishes alerts to event service using the typed event AlertStatusEvent.
Definition: alertService.hpp:106
Simple alert observer that writes alerts to log.
Definition: alertService.hpp:89
Alert Service interface.
Definition: alertServiceIf.hpp:315
Implementation of AlertServiceIf.
Definition: alertService.hpp:29
ReducedStatus GetReducedStatus() const override
Get the reduced status.
Definition: alertService.cpp:35
std::vector< AlertStatus > GetAlertStatuses() const override
Get status of all alert conditions.
Definition: alertService.cpp:40
AlertSource MakeAlertSource(AlertDescription const &description) override
Creates a new alert source for the specified alert condition.
Definition: alertService.cpp:59
~AlertService() noexcept
Destructor will automatically stop notifier.
Definition: alertService.cpp:32
boost::signals2::connection ConnectReducedStatus(ReducedStatusSignal::slot_type slot) override
Connects a slot to the reduced alert signal.
Definition: alertService.cpp:54
Models a single alert source that can be set or cleared.
Definition: alertServiceIf.hpp:48
std::chrono::system_clock::time_point TimePoint
Timestamp type.
Definition: alertServiceIf.hpp:74
Interface to observe alert status.
Definition: alertServiceIf.hpp:209
boost::signals2::signal< void(ReducedStatus const &, std::vector< AlertStatus > const &)> ReducedStatusSignal
Signal emitted for every change in reduced alert status.
Definition: alertServiceIf.hpp:264
std::optional< bool > ReducedStatus
Represents current alert status.
Definition: alertServiceIf.hpp:220
Interface class for providing pub/sub facilities for JSON events.
Definition: eventServiceIf.hpp:29
A high-level event service API that is aware of event types.
Definition: typedEventService.hpp:248
Framework-provided event definitions.
Definition: commandReplier.cpp:22
Structure describing an alert condition with status from the corresponding AlertSource.
Definition: alertServiceIf.hpp:230
High-level API of the event service.