blob: f49be6dd8f20fc3a9fc3aba8d5e3df22b895b894 [file] [log] [blame]
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02001#pragma once
2
3#include "interfaces/report_factory.hpp"
Wludzik, Jozefe2362792020-10-27 17:23:55 +01004#include "interfaces/sensor.hpp"
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +01005#include "sensor_cache.hpp"
Szymon Dompke94f71c52021-12-10 07:16:33 +01006#include "types/sensor_types.hpp"
Szymon Dompkefdb06a12022-02-11 11:04:44 +01007#include "utils/dbus_mapper.hpp"
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02008
9#include <boost/asio/io_context.hpp>
10#include <sdbusplus/asio/object_server.hpp>
11
12class ReportFactory : public interfaces::ReportFactory
13{
14 public:
15 ReportFactory(
Wludzik, Jozefe2362792020-10-27 17:23:55 +010016 std::shared_ptr<sdbusplus::asio::connection> bus,
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010017 const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
18 SensorCache& sensorCache);
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020019
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000020 std::vector<LabeledMetricParameters> convertMetricParams(
21 boost::asio::yield_context& yield,
22 const ReadingParameters& metricParams) const override;
23
Szymon Dompkefdb06a12022-02-11 11:04:44 +010024 std::vector<LabeledMetricParameters> convertMetricParams(
25 const ReadingParameters& metricParams) const override;
26
Szymon Dompke32305f12022-07-05 15:37:21 +020027 void updateMetrics(
28 std::vector<std::shared_ptr<interfaces::Metric>>& metrics, bool enabled,
29 const std::vector<LabeledMetricParameters>& labeledMetricParams)
30 const override;
Szymon Dompkefdb06a12022-02-11 11:04:44 +010031
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010032 std::unique_ptr<interfaces::Report>
33 make(const std::string& reportId, const std::string& name,
34 const ReportingType reportingType,
35 const std::vector<ReportAction>& reportActions,
36 Milliseconds period, uint64_t appendLimitIn,
37 const ReportUpdates reportUpdatesIn,
38 interfaces::ReportManager& reportManager,
39 interfaces::JsonStorage& reportStorage,
40 std::vector<LabeledMetricParameters> labeledMetricParams,
Krzysztof Grobelny493e62e2022-02-14 10:55:50 +010041 bool enabled, Readings) const override;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020042
43 private:
Szymon Dompke94f71c52021-12-10 07:16:33 +010044 Sensors getSensors(const std::vector<LabeledSensorInfo>& sensorPaths) const;
Szymon Dompkefdb06a12022-02-11 11:04:44 +010045 std::vector<LabeledMetricParameters> getMetricParamsFromSensorTree(
46 const ReadingParameters& metricParams,
47 const std::vector<utils::SensorTree>& tree) const;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010048
Wludzik, Jozefe2362792020-10-27 17:23:55 +010049 std::shared_ptr<sdbusplus::asio::connection> bus;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020050 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010051 SensorCache& sensorCache;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020052};