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, 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); 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 44 bool storeConfiguration() const; 45 46 private: 47 const std::string name; 48 bool isDiscrete; 49 bool logToJournal; 50 bool logToRedfish; 51 bool updateReport; 52 const std::string path; 53 bool persistent = false; 54 std::vector<std::string> reportNames; 55 std::vector<LabeledSensorInfo> labeledSensorsInfo; 56 LabeledTriggerThresholdParams labeledThresholdParams; 57 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; 58 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; 59 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; 60 61 interfaces::JsonStorage::FilePath fileName; 62 interfaces::JsonStorage& triggerStorage; 63 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"; 71 static constexpr size_t triggerVersion = 0; 72 }; 73