1 #pragma once 2 3 #include "interfaces/report_factory.hpp" 4 #include "interfaces/sensor.hpp" 5 #include "sensor_cache.hpp" 6 #include "types/sensor_types.hpp" 7 #include "utils/dbus_mapper.hpp" 8 9 #include <boost/asio/io_context.hpp> 10 #include <sdbusplus/asio/object_server.hpp> 11 12 class ReportFactory : public interfaces::ReportFactory 13 { 14 public: 15 ReportFactory( 16 std::shared_ptr<sdbusplus::asio::connection> bus, 17 const std::shared_ptr<sdbusplus::asio::object_server>& objServer, 18 SensorCache& sensorCache); 19 20 std::vector<LabeledMetricParameters> convertMetricParams( 21 boost::asio::yield_context& yield, 22 const ReadingParameters& metricParams) const override; 23 24 std::vector<LabeledMetricParameters> convertMetricParams( 25 const ReadingParameters& metricParams) const override; 26 27 void 28 updateMetrics(std::vector<std::shared_ptr<interfaces::Metric>>& metrics, 29 bool enabled, 30 const ReadingParameters& metricParams) const override; 31 32 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, 41 bool enabled, Readings) const override; 42 43 private: 44 Sensors getSensors(const std::vector<LabeledSensorInfo>& sensorPaths) const; 45 std::vector<LabeledMetricParameters> getMetricParamsFromSensorTree( 46 const ReadingParameters& metricParams, 47 const std::vector<utils::SensorTree>& tree) const; 48 49 std::shared_ptr<sdbusplus::asio::connection> bus; 50 std::shared_ptr<sdbusplus::asio::object_server> objServer; 51 SensorCache& sensorCache; 52 }; 53