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