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 | |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame^] | 17 | 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, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 34 | |
| 35 | private: |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 36 | 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 Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame^] | 43 | const std::vector<LabeledSensorParameters>& sensorPaths) const; |
| 44 | std::vector<LabeledMetricParameters> |
| 45 | convertMetricParams(boost::asio::yield_context& yield, |
| 46 | const ReadingParameters& metricParams) const; |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 47 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 48 | std::shared_ptr<sdbusplus::asio::connection> bus; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 49 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 50 | mutable SensorCache sensorCache; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 51 | }; |