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" |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 6 | #include "interfaces/trigger_factory.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 7 | #include "interfaces/trigger_manager.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 8 | #include "types/trigger_types.hpp" |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame^] | 9 | #include "utils/messanger.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 10 | |
| 11 | #include <boost/asio/io_context.hpp> |
| 12 | #include <sdbusplus/asio/object_server.hpp> |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | class Trigger : public interfaces::Trigger |
| 17 | { |
| 18 | public: |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 19 | Trigger(boost::asio::io_context& ioc, |
| 20 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 21 | const std::string& id, const std::string& name, |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 22 | const std::vector<TriggerAction>& triggerActions, |
| 23 | const std::shared_ptr<std::vector<std::string>> reportIds, |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 24 | std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, |
| 25 | interfaces::TriggerManager& triggerManager, |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 26 | interfaces::JsonStorage& triggerStorage, |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame^] | 27 | const interfaces::TriggerFactory& triggerFactory, |
| 28 | Sensors sensorsIn); |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 29 | |
| 30 | Trigger(const Trigger&) = delete; |
| 31 | Trigger(Trigger&&) = delete; |
| 32 | Trigger& operator=(const Trigger&) = delete; |
| 33 | Trigger& operator=(Trigger&&) = delete; |
| 34 | |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 35 | std::string getId() const override |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 36 | { |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 37 | return id; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | std::string getPath() const override |
| 41 | { |
| 42 | return path; |
| 43 | } |
| 44 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 45 | bool storeConfiguration() const; |
| 46 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 47 | private: |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 48 | std::string id; |
| 49 | std::string name; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 50 | std::vector<TriggerAction> triggerActions; |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 51 | std::string path; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 52 | bool persistent = false; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 53 | std::shared_ptr<std::vector<std::string>> reportIds; |
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; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 60 | Sensors sensors; |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame^] | 61 | utils::Messanger messanger; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 62 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 63 | public: |
| 64 | static constexpr const char* triggerIfaceName = |
| 65 | "xyz.openbmc_project.Telemetry.Trigger"; |
| 66 | static constexpr const char* triggerDir = |
| 67 | "/xyz/openbmc_project/Telemetry/Triggers/"; |
| 68 | static constexpr const char* deleteIfaceName = |
| 69 | "xyz.openbmc_project.Object.Delete"; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 70 | static constexpr size_t triggerVersion = 1; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 71 | }; |