blob: da371585b5d3356dea0ca8737434ac4c6f87fd73 [file] [log] [blame]
kasunath7cea1b92022-06-14 20:23:27 -07001#pragma once
2
kasunath7cea1b92022-06-14 20:23:27 -07003#include <sdbusplus/server.hpp>
4#include <xyz/openbmc_project/Common/FilePath/server.hpp>
5
Patrick Williams5de90612024-02-13 21:31:53 -06006#include <format>
kasunath7cea1b92022-06-14 20:23:27 -07007#include <string>
8
9namespace bios_bmc_smm_error_logger
10{
11
12using FileNotifierInterface = sdbusplus::server::object_t<
13 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
14
15/**
16 * @brief A class for notifying file paths of CPER logs.
17 */
18class CperFileNotifier : public FileNotifierInterface
19{
20 public:
21 /**
22 * @brief Constructor for the CperFileNotifier class.
23 *
24 * @param bus - bus to attach to.
25 * @param filePath - full path of the CPER log JSON file.
26 * @param entry - index of the DBus file path object.
27 */
Patrick Williamsbea36e22022-07-22 19:26:57 -050028 CperFileNotifier(sdbusplus::bus_t& bus, const std::string& filePath,
kasunath7cea1b92022-06-14 20:23:27 -070029 uint64_t entry) :
30 FileNotifierInterface(bus, generatePath(entry).c_str(),
Edward Lee3cbb6ef2023-03-15 17:08:40 +000031 action::emit_no_signals)
kasunath7cea1b92022-06-14 20:23:27 -070032 {
33 // We only need the interface added signal for the fault monitor. So
34 // stop emitting properties changed signal.
35 path(filePath, /*skipSignal=*/true);
36 }
37
38 static constexpr const char* cperBasePath =
39 "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER";
40
41 private:
42 /**
kasunath7cea1b92022-06-14 20:23:27 -070043 * @brief Generate a path for the CperFileNotifier DBus object.
44 *
45 * @param[in] entry - unique index for the DBus object.
46 */
47 std::string generatePath(uint64_t entry)
48 {
Patrick Williams5de90612024-02-13 21:31:53 -060049 return std::format("{}/entry{}", cperBasePath, entry);
kasunath7cea1b92022-06-14 20:23:27 -070050 }
51};
52
53} // namespace bios_bmc_smm_error_logger