blob: 83c92f9d34fa15763c46d937f1467b4a06c2a6fe [file] [log] [blame]
kasunath7cea1b92022-06-14 20:23:27 -07001#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
10namespace bios_bmc_smm_error_logger
11{
12
13using 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 */
19class 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 Williamsbea36e22022-07-22 19:26:57 -050029 CperFileNotifier(sdbusplus::bus_t& bus, const std::string& filePath,
kasunath7cea1b92022-06-14 20:23:27 -070030 uint64_t entry) :
31 FileNotifierInterface(bus, generatePath(entry).c_str(),
Edward Lee3cbb6ef2023-03-15 17:08:40 +000032 action::emit_no_signals)
kasunath7cea1b92022-06-14 20:23:27 -070033 {
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 /**
kasunath7cea1b92022-06-14 20:23:27 -070044 * @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