1 #pragma once 2 3 #include "interfaces/report_manager.hpp" 4 #include "interfaces/trigger_factory.hpp" 5 #include "interfaces/trigger_manager.hpp" 6 #include "trigger.hpp" 7 8 #include <sdbusplus/asio/object_server.hpp> 9 10 #include <memory> 11 #include <vector> 12 13 class TriggerManager : public interfaces::TriggerManager 14 { 15 public: 16 TriggerManager( 17 std::unique_ptr<interfaces::TriggerFactory> triggerFactory, 18 std::unique_ptr<interfaces::JsonStorage> triggerStorage, 19 const std::shared_ptr<sdbusplus::asio::object_server>& objServer); 20 21 TriggerManager(const TriggerManager&) = delete; 22 TriggerManager(TriggerManager&&) = delete; 23 TriggerManager& operator=(const TriggerManager&) = delete; 24 TriggerManager& operator=(TriggerManager&&) = delete; 25 26 void removeTrigger(const interfaces::Trigger* trigger) override; 27 28 static void verifyReportIds(const std::vector<std::string>& newReportIds); 29 30 private: 31 std::unique_ptr<interfaces::TriggerFactory> triggerFactory; 32 std::unique_ptr<interfaces::JsonStorage> triggerStorage; 33 std::unique_ptr<sdbusplus::asio::dbus_interface> managerIface; 34 std::vector<std::unique_ptr<interfaces::Trigger>> triggers; 35 36 void verifyAddTrigger(const std::string& triggerId, 37 const std::string& triggerName, 38 const std::vector<std::string>& newReportIds) const; 39 40 interfaces::Trigger& 41 addTrigger(const std::string& triggerId, const std::string& triggerName, 42 const std::vector<std::string>& triggerActions, 43 const std::vector<LabeledSensorInfo>& labeledSensors, 44 const std::vector<std::string>& reportIds, 45 const LabeledTriggerThresholdParams& labeledThresholdParams); 46 void loadFromPersistent(); 47 48 public: 49 static constexpr size_t maxTriggers{TELEMETRY_MAX_TRIGGERS}; 50 static constexpr size_t maxTriggerIdLength{ 51 TELEMETRY_MAX_DBUS_PATH_LENGTH - 52 std::string_view(Trigger::triggerDir).length()}; 53 static constexpr const char* triggerManagerIfaceName = 54 "xyz.openbmc_project.Telemetry.TriggerManager"; 55 static constexpr const char* triggerManagerPath = 56 "/xyz/openbmc_project/Telemetry/Triggers"; 57 static constexpr const char* triggerNameDefault = "Trigger"; 58 }; 59