Coverage Report

Created: 2026-01-25 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bios-bmc-smm-error-logger/include/dbus/file_notifier.hpp
Line
Count
Source
1
#pragma once
2
3
#include <sdbusplus/asio/object_server.hpp>
4
#include <xyz/openbmc_project/Common/FilePath/server.hpp>
5
6
#include <format>
7
#include <string>
8
9
namespace bios_bmc_smm_error_logger
10
{
11
12
/**
13
 * @brief A class for notifying file paths of CPER logs.
14
 */
15
class CperFileNotifier
16
{
17
  public:
18
    /**
19
     * @brief Constructor for the CperFileNotifier class.
20
     *
21
     * @param server - sdbusplus asio object server.
22
     * @param filePath - full path of the CPER log JSON file.
23
     * @param entry - index of the DBus file path object.
24
     */
25
    CperFileNotifier(sdbusplus::asio::object_server& server,
26
                     const std::string& filePath, uint64_t entry) :
27
        server(server)
28
0
    {
29
0
        pathIface = server.add_interface(generatePath(entry).c_str(),
30
0
                                         "xyz.openbmc_project.Common.FilePath");
31
0
        pathIface->register_property("Path", filePath);
32
0
        pathIface->initialize();
33
0
    }
34
35
    ~CperFileNotifier()
36
0
    {
37
0
        server.remove_interface(pathIface);
38
0
    }
39
40
    CperFileNotifier& operator=(const CperFileNotifier&) = delete;
41
    CperFileNotifier& operator=(CperFileNotifier&&) = delete;
42
    CperFileNotifier(const CperFileNotifier&) = delete;
43
    CperFileNotifier(CperFileNotifier&&) = default;
44
45
    static constexpr const char* cperBasePath =
46
        "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER";
47
48
  private:
49
    sdbusplus::asio::object_server& server;
50
    std::shared_ptr<sdbusplus::asio::dbus_interface> pathIface;
51
52
    /**
53
     * @brief Generate a path for the CperFileNotifier DBus object.
54
     *
55
     * @param[in] entry - unique index for the DBus object.
56
     */
57
    std::string generatePath(uint64_t entry)
58
0
    {
59
0
        return std::format("{}/entry{}", cperBasePath, entry);
60
0
    }
61
};
62
63
} // namespace bios_bmc_smm_error_logger