blob: c887ab24300d74bb615ade63dad7a69859121aa5 [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(),
32 action::emit_no_signals),
33 entry(entry), bus(bus)
34 {
35 // We only need the interface added signal for the fault monitor. So
36 // stop emitting properties changed signal.
37 path(filePath, /*skipSignal=*/true);
38 }
39
40 static constexpr const char* cperBasePath =
41 "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER";
42
43 private:
44 /**
45 * @brief DBus index of the entry.
46 */
47 uint64_t entry;
48
Patrick Williamsbea36e22022-07-22 19:26:57 -050049 sdbusplus::bus_t& bus;
kasunath7cea1b92022-06-14 20:23:27 -070050
51 /**
52 * @brief Generate a path for the CperFileNotifier DBus object.
53 *
54 * @param[in] entry - unique index for the DBus object.
55 */
56 std::string generatePath(uint64_t entry)
57 {
58 return fmt::format("{}/entry{}", cperBasePath, entry);
59 }
60};
61
62} // namespace bios_bmc_smm_error_logger