blob: a26b59ed60b3a72d30ecc5ffc2525e32d515b434 [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001#pragma once
2
Wludzik, Jozefe2362792020-10-27 17:23:55 +01003#include "interfaces/json_storage.hpp"
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02004#include "interfaces/report.hpp"
5#include "interfaces/report_factory.hpp"
6#include "interfaces/report_manager.hpp"
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +02007
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02008#include <sdbusplus/asio/object_server.hpp>
9
10#include <chrono>
11#include <memory>
12#include <vector>
13
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020014class ReportManager : public interfaces::ReportManager
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020015{
16 public:
17 ReportManager(
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020018 std::unique_ptr<interfaces::ReportFactory> reportFactory,
Wludzik, Jozefe2362792020-10-27 17:23:55 +010019 std::unique_ptr<interfaces::JsonStorage> reportStorage,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020020 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020021 ~ReportManager() = default;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020022
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020023 ReportManager(ReportManager&) = delete;
24 ReportManager(ReportManager&&) = delete;
25 ReportManager& operator=(ReportManager&) = delete;
26 ReportManager& operator=(ReportManager&&) = delete;
27
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020028 void removeReport(const interfaces::Report* report) override;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020029 static bool verifyScanPeriod(const uint64_t scanPeriod);
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020030
31 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020032 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010033 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020034 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020035 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020036 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020037
Wludzik, Jozefe2362792020-10-27 17:23:55 +010038 std::unique_ptr<interfaces::Report>& addReport(
39 std::optional<std::reference_wrapper<boost::asio::yield_context>> yield,
40 const std::string& reportName, const std::string& reportingType,
41 const bool emitsReadingsUpdate, const bool logToMetricReportsCollection,
42 std::chrono::milliseconds interval,
43 const ReadingParameters& metricParams);
44 void loadFromPersistent();
45
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020046 public:
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020047 static constexpr uint32_t maxReports{20};
48 static constexpr std::chrono::milliseconds minInterval{1000};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020049 static constexpr const char* reportManagerIfaceName =
50 "xyz.openbmc_project.Telemetry.ReportManager";
51 static constexpr const char* reportManagerPath =
52 "/xyz/openbmc_project/Telemetry/Reports";
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020053};