kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <fmt/format.h> |
| 4 | |
| 5 | #include <sdbusplus/server.hpp> |
| 6 | #include <xyz/openbmc_project/Common/FilePath/server.hpp> |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | namespace bios_bmc_smm_error_logger |
| 11 | { |
| 12 | |
| 13 | using FileNotifierInterface = sdbusplus::server::object_t< |
| 14 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
| 15 | |
| 16 | /** |
| 17 | * @brief A class for notifying file paths of CPER logs. |
| 18 | */ |
| 19 | class CperFileNotifier : public FileNotifierInterface |
| 20 | { |
| 21 | public: |
| 22 | /** |
| 23 | * @brief Constructor for the CperFileNotifier class. |
| 24 | * |
| 25 | * @param bus - bus to attach to. |
| 26 | * @param filePath - full path of the CPER log JSON file. |
| 27 | * @param entry - index of the DBus file path object. |
| 28 | */ |
Patrick Williams | bea36e2 | 2022-07-22 19:26:57 -0500 | [diff] [blame] | 29 | CperFileNotifier(sdbusplus::bus_t& bus, const std::string& filePath, |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 30 | uint64_t entry) : |
| 31 | FileNotifierInterface(bus, generatePath(entry).c_str(), |
Edward Lee | 3cbb6ef | 2023-03-15 17:08:40 +0000 | [diff] [blame] | 32 | action::emit_no_signals) |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 33 | { |
| 34 | // We only need the interface added signal for the fault monitor. So |
| 35 | // stop emitting properties changed signal. |
| 36 | path(filePath, /*skipSignal=*/true); |
| 37 | } |
| 38 | |
| 39 | static constexpr const char* cperBasePath = |
| 40 | "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER"; |
| 41 | |
| 42 | private: |
| 43 | /** |
kasunath | 7cea1b9 | 2022-06-14 20:23:27 -0700 | [diff] [blame] | 44 | * @brief Generate a path for the CperFileNotifier DBus object. |
| 45 | * |
| 46 | * @param[in] entry - unique index for the DBus object. |
| 47 | */ |
| 48 | std::string generatePath(uint64_t entry) |
| 49 | { |
| 50 | return fmt::format("{}/entry{}", cperBasePath, entry); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | } // namespace bios_bmc_smm_error_logger |