blob: c180c3dbc473b668de7074e96d2291be7c1b6517 [file] [log] [blame]
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01001#pragma once
2
3#include "interfaces/report_manager.hpp"
4#include "interfaces/trigger_action.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00005#include "types/trigger_types.hpp"
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01006
7namespace action
8{
9
Szymon Dompkef763c9e2021-03-12 09:19:22 +010010namespace numeric
11{
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010012class LogToJournal : public interfaces::TriggerAction
13{
14 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010015 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010016 {}
17
18 void commit(const std::string& id, uint64_t timestamp,
19 double value) override;
20
21 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010022 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010023 double threshold;
24
25 const char* getType() const;
26};
27
28class LogToRedfish : public interfaces::TriggerAction
29{
30 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010031 LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010032 {}
33
34 void commit(const std::string& id, uint64_t timestamp,
35 double value) override;
36
37 private:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010038 ::numeric::Type type;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010039 double threshold;
40
41 const char* getMessageId() const;
42};
Szymon Dompke20013012021-07-23 09:54:20 +020043
44void fillActions(
45 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
46 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type,
47 double thresholdValue, interfaces::ReportManager& reportManager,
48 const std::vector<std::string>& reportNames);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010049} // namespace numeric
50
51namespace discrete
52{
53class LogToJournal : public interfaces::TriggerAction
54{
55 public:
56 LogToJournal(::discrete::Severity severity) : severity(severity)
57 {}
58
59 void commit(const std::string& id, uint64_t timestamp,
60 double value) override;
61
62 private:
63 ::discrete::Severity severity;
64
65 const char* getSeverity() const;
66};
67
68class LogToRedfish : public interfaces::TriggerAction
69{
70 public:
71 LogToRedfish(::discrete::Severity severity) : severity(severity)
72 {}
73
74 void commit(const std::string& id, uint64_t timestamp,
75 double value) override;
76
77 private:
78 ::discrete::Severity severity;
79
80 const char* getMessageId() const;
81};
82
Szymon Dompke20013012021-07-23 09:54:20 +020083void fillActions(
84 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
85 const std::vector<TriggerAction>& ActionsEnum,
86 ::discrete::Severity severity, interfaces::ReportManager& reportManager,
87 const std::vector<std::string>& reportNames);
88
Szymon Dompkef763c9e2021-03-12 09:19:22 +010089namespace onChange
90{
91class LogToJournal : public interfaces::TriggerAction
92{
93 public:
94 LogToJournal()
95 {}
96
97 void commit(const std::string& id, uint64_t timestamp,
98 double value) override;
99};
100
101class LogToRedfish : public interfaces::TriggerAction
102{
103 public:
104 LogToRedfish()
105 {}
106
107 void commit(const std::string& id, uint64_t timestamp,
108 double value) override;
109};
Szymon Dompke20013012021-07-23 09:54:20 +0200110
111void fillActions(
112 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
113 const std::vector<TriggerAction>& ActionsEnum,
114 interfaces::ReportManager& reportManager,
115 const std::vector<std::string>& reportNames);
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100116} // namespace onChange
117
118} // namespace discrete
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100119
120class UpdateReport : public interfaces::TriggerAction
121{
122 public:
123 UpdateReport(interfaces::ReportManager& reportManager,
124 std::vector<std::string> names) :
125 reportManager(reportManager),
126 reportNames(std::move(names))
127 {}
128
129 void commit(const std::string& id, uint64_t timestamp,
130 double value) override;
131
132 private:
133 interfaces::ReportManager& reportManager;
134 std::vector<std::string> reportNames;
135};
136} // namespace action