xref: /openbmc/telemetry/src/trigger_factory.hpp (revision 4416fce6fb6539b4e2a6a94a8248934c2eb29820)
1 #pragma once
2 
3 #include "interfaces/report_manager.hpp"
4 #include "interfaces/sensor.hpp"
5 #include "interfaces/trigger_factory.hpp"
6 #include "sensor_cache.hpp"
7 
8 #include <sdbusplus/asio/object_server.hpp>
9 
10 class TriggerFactory : public interfaces::TriggerFactory
11 {
12   public:
13     TriggerFactory(std::shared_ptr<sdbusplus::asio::connection> bus,
14                    std::shared_ptr<sdbusplus::asio::object_server> objServer,
15                    SensorCache& sensorCache,
16                    interfaces::ReportManager& reportManager);
17 
18     std::unique_ptr<interfaces::Trigger>
19         make(const std::string& name, bool isDiscrete, bool logToJournal,
20              bool logToRedfish, bool updateReport,
21              const std::vector<std::string>& reportNames,
22              interfaces::TriggerManager& triggerManager,
23              interfaces::JsonStorage& triggerStorage,
24              const LabeledTriggerThresholdParams& labeledThresholdParams,
25              const std::vector<LabeledSensorInfo>& labeledSensorsinfo)
26             const override;
27 
28     std::vector<LabeledSensorInfo>
29         getLabeledSensorsInfo(boost::asio::yield_context& yield,
30                               const SensorsInfo& sensorsInfo) const;
31 
32   private:
33     std::shared_ptr<sdbusplus::asio::connection> bus;
34     std::shared_ptr<sdbusplus::asio::object_server> objServer;
35     SensorCache& sensorCache;
36     interfaces::ReportManager& reportManager;
37 
38     std::pair<std::vector<std::shared_ptr<interfaces::Sensor>>,
39               std::vector<std::string>>
40         getSensors(
41             const std::vector<LabeledSensorInfo>& labeledSensorsInfo) const;
42 };
43