blob: 9ae2197d26a8eb43212e510b220ad65c9b9049b7 [file] [log] [blame]
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01001#pragma once
2
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01003#include "interfaces/report_manager.hpp"
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01004#include "interfaces/sensor.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01005#include "interfaces/trigger_factory.hpp"
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01006#include "sensor_cache.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01007
8#include <sdbusplus/asio/object_server.hpp>
9
10class TriggerFactory : public interfaces::TriggerFactory
11{
12 public:
13 TriggerFactory(std::shared_ptr<sdbusplus::asio::connection> bus,
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010014 std::shared_ptr<sdbusplus::asio::object_server> objServer,
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010015 SensorCache& sensorCache,
16 interfaces::ReportManager& reportManager);
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010017
Cezary Zwolak4416fce2021-03-17 03:21:06 +010018 std::unique_ptr<interfaces::Trigger>
Szymon Dompkee28aa532021-10-27 12:33:12 +020019 make(const std::string& id, const std::string& name,
Szymon Dompke20013012021-07-23 09:54:20 +020020 const std::vector<std::string>& triggerActions,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010021 const std::vector<std::string>& reportIds,
Cezary Zwolak4416fce2021-03-17 03:21:06 +010022 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;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010031
32 private:
33 std::shared_ptr<sdbusplus::asio::connection> bus;
34 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010035 SensorCache& sensorCache;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010036 interfaces::ReportManager& reportManager;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010037
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000038 std::pair<Sensors, std::vector<std::string>> getSensors(
39 const std::vector<LabeledSensorInfo>& labeledSensorsInfo) const;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010040};