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 "interfaces/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( 18 boost::asio::io_context& ioc, 19 const std::shared_ptr<sdbusplus::asio::object_server>& objServer, 20 const std::string& name, const bool isDiscrete, const bool logToJournal, 21 const bool logToRedfish, const bool updateReport, 22 const std::vector< 23 std::pair<sdbusplus::message::object_path, std::string>>& sensorsIn, 24 const std::vector<std::string>& reportNames, 25 const TriggerThresholdParams& thresholdParams, 26 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, 27 interfaces::TriggerManager& triggerManager, 28 interfaces::JsonStorage& triggerStorage); 29 30 Trigger(const Trigger&) = delete; 31 Trigger(Trigger&&) = delete; 32 Trigger& operator=(const Trigger&) = delete; 33 Trigger& operator=(Trigger&&) = delete; 34 35 std::string getName() const override 36 { 37 return name; 38 } 39 40 std::string getPath() const override 41 { 42 return path; 43 } 44 45 bool storeConfiguration() const; 46 47 private: 48 const std::string name; 49 bool isDiscrete; 50 bool logToJournal; 51 bool logToRedfish; 52 bool updateReport; 53 const std::string path; 54 bool persistent = false; 55 TriggerSensors sensors; 56 std::vector<std::string> reportNames; 57 TriggerThresholdParams thresholdParams; 58 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; 59 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; 60 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; 61 62 interfaces::JsonStorage::FilePath fileName; 63 interfaces::JsonStorage& triggerStorage; 64 65 public: 66 static constexpr const char* triggerIfaceName = 67 "xyz.openbmc_project.Telemetry.Trigger"; 68 static constexpr const char* triggerDir = 69 "/xyz/openbmc_project/Telemetry/Triggers/"; 70 static constexpr const char* deleteIfaceName = 71 "xyz.openbmc_project.Object.Delete"; 72 static constexpr size_t triggerVersion = 0; 73 }; 74