1 #pragma once 2 3 #include "interfaces/threshold.hpp" 4 #include "interfaces/trigger.hpp" 5 #include "interfaces/trigger_manager.hpp" 6 #include "interfaces/trigger_types.hpp" 7 8 #include <boost/asio/io_context.hpp> 9 #include <sdbusplus/asio/object_server.hpp> 10 11 #include <memory> 12 13 class Trigger : public interfaces::Trigger 14 { 15 public: 16 Trigger( 17 boost::asio::io_context& ioc, 18 const std::shared_ptr<sdbusplus::asio::object_server>& objServer, 19 const std::string& name, const bool isDiscrete, const bool logToJournal, 20 const bool logToRedfish, const bool updateReport, 21 const std::vector< 22 std::pair<sdbusplus::message::object_path, std::string>>& sensorsIn, 23 const std::vector<std::string>& reportNames, 24 const TriggerThresholdParams& thresholdParams, 25 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, 26 interfaces::TriggerManager& triggerManager); 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 private: 44 const std::string name; 45 const std::string path; 46 bool persistent; 47 std::vector<std::pair<sdbusplus::message::object_path, std::string>> 48 sensors; 49 std::vector<std::string> reportNames; 50 TriggerThresholdParams thresholdParams; 51 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; 52 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; 53 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; 54 55 public: 56 static constexpr const char* triggerIfaceName = 57 "xyz.openbmc_project.Telemetry.Trigger"; 58 static constexpr const char* triggerDir = 59 "/xyz/openbmc_project/Telemetry/Triggers/"; 60 static constexpr const char* deleteIfaceName = 61 "xyz.openbmc_project.Object.Delete"; 62 }; 63