Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 3 | #include "interfaces/json_storage.hpp" |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 4 | #include "interfaces/threshold.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 5 | #include "interfaces/trigger.hpp" |
| 6 | #include "interfaces/trigger_manager.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 7 | #include "types/trigger_types.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 8 | |
| 9 | #include <boost/asio/io_context.hpp> |
| 10 | #include <sdbusplus/asio/object_server.hpp> |
| 11 | |
| 12 | #include <memory> |
| 13 | |
| 14 | class Trigger : public interfaces::Trigger |
| 15 | { |
| 16 | public: |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 17 | Trigger(boost::asio::io_context& ioc, |
| 18 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 19 | const std::string& id, const std::string& name, |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 20 | const std::vector<std::string>& triggerActions, |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 21 | const std::vector<std::string>& reportNames, |
| 22 | const std::vector<LabeledSensorInfo>& LabeledSensorsInfoIn, |
| 23 | const LabeledTriggerThresholdParams& labeledThresholdParamsIn, |
| 24 | std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, |
| 25 | interfaces::TriggerManager& triggerManager, |
| 26 | interfaces::JsonStorage& triggerStorage); |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 27 | |
| 28 | Trigger(const Trigger&) = delete; |
| 29 | Trigger(Trigger&&) = delete; |
| 30 | Trigger& operator=(const Trigger&) = delete; |
| 31 | Trigger& operator=(Trigger&&) = delete; |
| 32 | |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 33 | std::string getId() const override |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 34 | { |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 35 | return id; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | std::string getPath() const override |
| 39 | { |
| 40 | return path; |
| 41 | } |
| 42 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 43 | bool storeConfiguration() const; |
| 44 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 45 | private: |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 46 | std::string id; |
| 47 | std::string name; |
Szymon Dompke | 2001301 | 2021-07-23 09:54:20 +0200 | [diff] [blame] | 48 | std::vector<std::string> triggerActions; |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 49 | std::string path; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 50 | bool persistent = false; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 51 | std::vector<std::string> reportNames; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 52 | std::vector<LabeledSensorInfo> labeledSensorsInfo; |
| 53 | LabeledTriggerThresholdParams labeledThresholdParams; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 54 | std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; |
| 55 | std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 56 | std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 57 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 58 | interfaces::JsonStorage::FilePath fileName; |
| 59 | interfaces::JsonStorage& triggerStorage; |
| 60 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 61 | public: |
| 62 | static constexpr const char* triggerIfaceName = |
| 63 | "xyz.openbmc_project.Telemetry.Trigger"; |
| 64 | static constexpr const char* triggerDir = |
| 65 | "/xyz/openbmc_project/Telemetry/Triggers/"; |
| 66 | static constexpr const char* deleteIfaceName = |
| 67 | "xyz.openbmc_project.Object.Delete"; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 68 | static constexpr size_t triggerVersion = 0; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 69 | }; |