blob: de2bc027a46daa54f29319481f6ad414c082bf01 [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"
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02006
7#include <boost/asio/io_context.hpp>
8#include <sdbusplus/asio/object_server.hpp>
9
10class ReportFactory : public interfaces::ReportFactory
11{
12 public:
13 ReportFactory(
Wludzik, Jozefe2362792020-10-27 17:23:55 +010014 std::shared_ptr<sdbusplus::asio::connection> bus,
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020015 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
16
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000017 std::unique_ptr<interfaces::Report>
18 make(boost::asio::yield_context& yield, const std::string& name,
19 const std::string& reportingType, bool emitsReadingsSignal,
20 bool logToMetricReportsCollection,
21 std::chrono::milliseconds period,
22 const ReadingParameters& metricParams,
23 interfaces::ReportManager& reportManager,
24 interfaces::JsonStorage& reportStorage) const override;
25 std::unique_ptr<interfaces::Report>
26 make(const std::string& name, const std::string& reportingType,
27 bool emitsReadingsSignal, bool logToMetricReportsCollection,
28 std::chrono::milliseconds period,
29 const ReadingParameters& metricParams,
30 interfaces::ReportManager& reportManager,
31 interfaces::JsonStorage& reportStorage,
32 std::vector<LabeledMetricParameters> labeledMetricParams)
33 const override;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020034
35 private:
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010036 using SensorPath = std::string;
37 using ServiceName = std::string;
38 using Ifaces = std::vector<std::string>;
39 using SensorIfaces = std::vector<std::pair<ServiceName, Ifaces>>;
40 using SensorTree = std::pair<SensorPath, SensorIfaces>;
41
42 std::vector<std::shared_ptr<interfaces::Sensor>> getSensors(
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000043 const std::vector<LabeledSensorParameters>& sensorPaths) const;
44 std::vector<LabeledMetricParameters>
45 convertMetricParams(boost::asio::yield_context& yield,
46 const ReadingParameters& metricParams) const;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010047
Wludzik, Jozefe2362792020-10-27 17:23:55 +010048 std::shared_ptr<sdbusplus::asio::connection> bus;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020049 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010050 mutable SensorCache sensorCache;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020051};