blob: f49be6dd8f20fc3a9fc3aba8d5e3df22b895b894 [file] [log] [blame]
#pragma once
#include "interfaces/report_factory.hpp"
#include "interfaces/sensor.hpp"
#include "sensor_cache.hpp"
#include "types/sensor_types.hpp"
#include "utils/dbus_mapper.hpp"
#include <boost/asio/io_context.hpp>
#include <sdbusplus/asio/object_server.hpp>
class ReportFactory : public interfaces::ReportFactory
{
public:
ReportFactory(
std::shared_ptr<sdbusplus::asio::connection> bus,
const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
SensorCache& sensorCache);
std::vector<LabeledMetricParameters> convertMetricParams(
boost::asio::yield_context& yield,
const ReadingParameters& metricParams) const override;
std::vector<LabeledMetricParameters> convertMetricParams(
const ReadingParameters& metricParams) const override;
void updateMetrics(
std::vector<std::shared_ptr<interfaces::Metric>>& metrics, bool enabled,
const std::vector<LabeledMetricParameters>& labeledMetricParams)
const override;
std::unique_ptr<interfaces::Report>
make(const std::string& reportId, const std::string& name,
const ReportingType reportingType,
const std::vector<ReportAction>& reportActions,
Milliseconds period, uint64_t appendLimitIn,
const ReportUpdates reportUpdatesIn,
interfaces::ReportManager& reportManager,
interfaces::JsonStorage& reportStorage,
std::vector<LabeledMetricParameters> labeledMetricParams,
bool enabled, Readings) const override;
private:
Sensors getSensors(const std::vector<LabeledSensorInfo>& sensorPaths) const;
std::vector<LabeledMetricParameters> getMetricParamsFromSensorTree(
const ReadingParameters& metricParams,
const std::vector<utils::SensorTree>& tree) const;
std::shared_ptr<sdbusplus::asio::connection> bus;
std::shared_ptr<sdbusplus::asio::object_server> objServer;
SensorCache& sensorCache;
};