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, |
| 19 | const std::string& name, const bool isDiscrete, |
| 20 | const bool logToJournal, const bool logToRedfish, |
| 21 | const bool updateReport, |
| 22 | const std::vector<std::string>& reportNames, |
| 23 | const std::vector<LabeledSensorInfo>& LabeledSensorsInfoIn, |
| 24 | const LabeledTriggerThresholdParams& labeledThresholdParamsIn, |
| 25 | std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, |
| 26 | interfaces::TriggerManager& triggerManager, |
| 27 | interfaces::JsonStorage& triggerStorage); |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 28 | |
| 29 | Trigger(const Trigger&) = delete; |
| 30 | Trigger(Trigger&&) = delete; |
| 31 | Trigger& operator=(const Trigger&) = delete; |
| 32 | Trigger& operator=(Trigger&&) = delete; |
| 33 | |
| 34 | std::string getName() const override |
| 35 | { |
| 36 | return name; |
| 37 | } |
| 38 | |
| 39 | std::string getPath() const override |
| 40 | { |
| 41 | return path; |
| 42 | } |
| 43 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 44 | bool storeConfiguration() const; |
| 45 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 46 | private: |
| 47 | const std::string name; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 48 | bool isDiscrete; |
| 49 | bool logToJournal; |
| 50 | bool logToRedfish; |
| 51 | bool updateReport; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 52 | const std::string path; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 53 | bool persistent = false; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 54 | std::vector<std::string> reportNames; |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 55 | std::vector<LabeledSensorInfo> labeledSensorsInfo; |
| 56 | LabeledTriggerThresholdParams labeledThresholdParams; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 57 | std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; |
| 58 | std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 59 | std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 60 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 61 | interfaces::JsonStorage::FilePath fileName; |
| 62 | interfaces::JsonStorage& triggerStorage; |
| 63 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 64 | public: |
| 65 | static constexpr const char* triggerIfaceName = |
| 66 | "xyz.openbmc_project.Telemetry.Trigger"; |
| 67 | static constexpr const char* triggerDir = |
| 68 | "/xyz/openbmc_project/Telemetry/Triggers/"; |
| 69 | static constexpr const char* deleteIfaceName = |
| 70 | "xyz.openbmc_project.Object.Delete"; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 71 | static constexpr size_t triggerVersion = 0; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 72 | }; |