1 #pragma once 2 3 #include "interfaces/json_storage.hpp" 4 #include "interfaces/threshold.hpp" 5 #include "interfaces/trigger.hpp" 6 #include "interfaces/trigger_manager.hpp" 7 #include "types/trigger_types.hpp" 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: 17 Trigger(boost::asio::io_context& ioc, 18 const std::shared_ptr<sdbusplus::asio::object_server>& objServer, 19 const std::string& name, 20 const std::vector<std::string>& triggerActions, 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); 27 28 Trigger(const Trigger&) = delete; 29 Trigger(Trigger&&) = delete; 30 Trigger& operator=(const Trigger&) = delete; 31 Trigger& operator=(Trigger&&) = delete; 32 33 std::string getName() const override 34 { 35 return name; 36 } 37 38 std::string getPath() const override 39 { 40 return path; 41 } 42 43 bool storeConfiguration() const; 44 45 private: 46 const std::string name; 47 std::vector<std::string> triggerActions; 48 const std::string path; 49 bool persistent = false; 50 std::vector<std::string> reportNames; 51 std::vector<LabeledSensorInfo> labeledSensorsInfo; 52 LabeledTriggerThresholdParams labeledThresholdParams; 53 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; 54 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; 55 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; 56 57 interfaces::JsonStorage::FilePath fileName; 58 interfaces::JsonStorage& triggerStorage; 59 60 public: 61 static constexpr const char* triggerIfaceName = 62 "xyz.openbmc_project.Telemetry.Trigger"; 63 static constexpr const char* triggerDir = 64 "/xyz/openbmc_project/Telemetry/Triggers/"; 65 static constexpr const char* deleteIfaceName = 66 "xyz.openbmc_project.Object.Delete"; 67 static constexpr size_t triggerVersion = 0; 68 }; 69