#pragma once #include "interfaces/clock.hpp" #include "interfaces/json_storage.hpp" #include "interfaces/metric.hpp" #include "interfaces/report.hpp" #include "interfaces/report_manager.hpp" #include "types/report_action.hpp" #include "types/report_types.hpp" #include "types/report_updates.hpp" #include "types/reporting_type.hpp" #include "utils/circular_vector.hpp" #include #include #include #include #include class Report : public interfaces::Report { public: Report(boost::asio::io_context& ioc, const std::shared_ptr& objServer, const std::string& reportId, const std::string& reportName, const ReportingType reportingType, std::vector reportActions, const Milliseconds period, const uint64_t appendLimitIn, const ReportUpdates reportUpdatesIn, interfaces::ReportManager& reportManager, interfaces::JsonStorage& reportStorage, std::vector> metrics, const bool enabled, std::unique_ptr clock); ~Report() = default; Report(const Report&) = delete; Report(Report&&) = delete; Report& operator=(const Report&) = delete; Report& operator=(Report&&) = delete; std::string getId() const override { return id; } std::string getPath() const override { return reportDir + id; } void updateReadings() override; bool storeConfiguration() const; private: std::unique_ptr makeReportInterface(); static void timerProc(boost::system::error_code, Report& self); void scheduleTimer(Milliseconds interval); uint64_t deduceAppendLimit(const uint64_t appendLimitIn) const; uint64_t deduceBufferSize(const ReportUpdates reportUpdatesIn, const ReportingType reportingTypeIn) const; void setReportUpdates(const ReportUpdates newReportUpdates); static uint64_t getSensorCount( std::vector>& metrics); interfaces::JsonStorage::FilePath fileName() const; std::string id; std::string name; ReportingType reportingType; Milliseconds interval; std::vector reportActions; ReadingParametersPastVersion readingParametersPastVersion; ReadingParameters readingParameters; bool persistency = false; uint64_t sensorCount; uint64_t appendLimit; ReportUpdates reportUpdates; CircularVector readingsBuffer; Readings readings = {}; std::shared_ptr objServer; std::unique_ptr reportIface; std::unique_ptr deleteIface; std::vector> metrics; boost::asio::steady_timer timer; interfaces::JsonStorage& reportStorage; bool enabled; std::unique_ptr clock; public: static constexpr const char* reportIfaceName = "xyz.openbmc_project.Telemetry.Report"; static constexpr const char* reportDir = "/xyz/openbmc_project/Telemetry/Reports/"; static constexpr const char* deleteIfaceName = "xyz.openbmc_project.Object.Delete"; static constexpr size_t reportVersion = 6; };