Add a class to create FilePath DBus objects
bios-bmc-smm-error-logger creates JSON entries for CPER logs received
from BIOS. When a new CPER log is created, fault log service has to be
notified.
This adds the necessary classes for publishing file paths of the newly
created CPER logs to DBus.
Tested:
Tested this on a real machine.
Eg DBus objects:
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/external_storer
`-/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger
`-/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER
|-/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER/entry0
|-/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER/entry1
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: I8c35243c949dfdc1254a758136d7a8e204f58bf5
diff --git a/include/rde/notifier_dbus_handler.hpp b/include/rde/notifier_dbus_handler.hpp
new file mode 100644
index 0000000..efcbd86
--- /dev/null
+++ b/include/rde/notifier_dbus_handler.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "dbus/file_notifier.hpp"
+
+#include <memory>
+#include <vector>
+
+namespace bios_bmc_smm_error_logger
+{
+namespace rde
+{
+
+/**
+ * @brief A class to handle CPER DBus notification objects.
+ */
+class CperFileNotifierHandler
+{
+ public:
+ /**
+ * @brief Constructor for the CperFileNotifierHandler class.
+ *
+ * @param bus - bus to attache to.
+ */
+ explicit CperFileNotifierHandler(sdbusplus::bus::bus& bus);
+
+ /**
+ * @brief Create a DBus object with the provided filePath value.
+ *
+ * @param filePath - file path of the CPER log JSON file.
+ */
+ void createEntry(const std::string& filePath);
+
+ private:
+ sdbusplus::bus::bus& bus;
+ sdbusplus::server::manager::manager objManager;
+
+ /**
+ * @brief A vector to keep track of DBus FilePath objects.
+ */
+ std::vector<std::unique_ptr<CperFileNotifier>> notifierObjs;
+
+ /**
+ * @brief DBus index of the next entry.
+ */
+ uint64_t nextEntry = 0;
+};
+
+} // namespace rde
+} // namespace bios_bmc_smm_error_logger