blob: 0346441ccd5a5711e6bd4e081fdc6caca43ac3c0 [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
Wludzik, Jozefe2362792020-10-27 17:23:55 +010017 std::unique_ptr<interfaces::Report> make(
18 std::optional<std::reference_wrapper<boost::asio::yield_context>> yield,
19 const std::string& name, const std::string& reportingType,
20 bool emitsReadingsSignal, bool logToMetricReportsCollection,
21 std::chrono::milliseconds period, const ReadingParameters& metricParams,
22 interfaces::ReportManager& reportManager,
23 interfaces::JsonStorage& reportStorage) const override;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020024
25 private:
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010026 using SensorPath = std::string;
27 using ServiceName = std::string;
28 using Ifaces = std::vector<std::string>;
29 using SensorIfaces = std::vector<std::pair<ServiceName, Ifaces>>;
30 using SensorTree = std::pair<SensorPath, SensorIfaces>;
31
32 std::vector<std::shared_ptr<interfaces::Sensor>> getSensors(
33 const std::optional<std::vector<SensorTree>>& tree,
34 const std::vector<sdbusplus::message::object_path>& sensorPaths) const;
35 std::vector<SensorTree>
36 getSensorTree(boost::asio::yield_context& yield) const;
37
Wludzik, Jozefe2362792020-10-27 17:23:55 +010038 std::shared_ptr<sdbusplus::asio::connection> bus;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020039 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010040 mutable SensorCache sensorCache;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020041};