Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interfaces/report_factory.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 4 | #include "interfaces/sensor.hpp" |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 5 | #include "sensor_cache.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 6 | |
| 7 | #include <boost/asio/io_context.hpp> |
| 8 | #include <sdbusplus/asio/object_server.hpp> |
| 9 | |
| 10 | class ReportFactory : public interfaces::ReportFactory |
| 11 | { |
| 12 | public: |
| 13 | ReportFactory( |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 14 | std::shared_ptr<sdbusplus::asio::connection> bus, |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 15 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer); |
| 16 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 17 | 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, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 24 | |
| 25 | private: |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 26 | 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, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 38 | std::shared_ptr<sdbusplus::asio::connection> bus; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 39 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 40 | mutable SensorCache sensorCache; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 41 | }; |