xref: /openbmc/telemetry/src/report_manager.hpp (revision e2362796befa500153beb22d3eae0a959bf825f4)
1 #pragma once
2 
3 #include "interfaces/json_storage.hpp"
4 #include "interfaces/report.hpp"
5 #include "interfaces/report_factory.hpp"
6 #include "interfaces/report_manager.hpp"
7 
8 #include <sdbusplus/asio/object_server.hpp>
9 
10 #include <chrono>
11 #include <memory>
12 #include <vector>
13 
14 class ReportManager : public interfaces::ReportManager
15 {
16   public:
17     ReportManager(
18         std::unique_ptr<interfaces::ReportFactory> reportFactory,
19         std::unique_ptr<interfaces::JsonStorage> reportStorage,
20         const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
21     ~ReportManager() = default;
22 
23     ReportManager(ReportManager&) = delete;
24     ReportManager(ReportManager&&) = delete;
25     ReportManager& operator=(ReportManager&) = delete;
26     ReportManager& operator=(ReportManager&&) = delete;
27 
28     void removeReport(const interfaces::Report* report) override;
29     static bool verifyScanPeriod(const uint64_t scanPeriod);
30 
31   private:
32     std::unique_ptr<interfaces::ReportFactory> reportFactory;
33     std::unique_ptr<interfaces::JsonStorage> reportStorage;
34     std::shared_ptr<sdbusplus::asio::object_server> objServer;
35     std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
36     std::vector<std::unique_ptr<interfaces::Report>> reports;
37 
38     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 
46   public:
47     static constexpr uint32_t maxReports{20};
48     static constexpr std::chrono::milliseconds minInterval{1000};
49     static constexpr const char* reportManagerIfaceName =
50         "xyz.openbmc_project.Telemetry.ReportManager";
51     static constexpr const char* reportManagerPath =
52         "/xyz/openbmc_project/Telemetry/Reports";
53 };
54