Add associations::Manager class
This class will handle creating the org.openbmc.Associations
D-Bus interfaces on inventory paths if it has been told to
by a JSON configuration file.
Every time PIM creates a new inventory path, this class will
check to see if any associations need to be created.
This functionality is optional, and is off by default. To
enable it, the --enable-associations configure option needs to
be used.
This commit just introduces the class.
Change-Id: I70045b768f3db683bcfac0c7d4bc9798eb10a5c5
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/association_manager.hpp b/association_manager.hpp
new file mode 100644
index 0000000..1aff7e0
--- /dev/null
+++ b/association_manager.hpp
@@ -0,0 +1,84 @@
+#pragma once
+
+#include "config.h"
+
+#include <sdbusplus/bus.hpp>
+
+namespace phosphor
+{
+namespace inventory
+{
+namespace manager
+{
+namespace associations
+{
+
+/**
+ * @class Manager
+ *
+ * @brief This class provides the ability to add org.openbmc.Associations
+ * interfaces on inventory D-Bus objects, based on a definition in a
+ * JSON file.
+ *
+ * The purpose for this is to be able to associate other D-Bus paths
+ * with the inventory items they relate to.
+ *
+ * For example, a card temperature sensor D-Bus object can be associated
+ * with the D-Bus object for that card's inventory entry so that some
+ * code can tie them together.
+ */
+class Manager
+{
+ public:
+ Manager() = delete;
+ ~Manager() = default;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = delete;
+ Manager& operator=(Manager&&) = delete;
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - sdbusplus object
+ * @param[in] jsonPath - path to the JSON File that contains associations
+ */
+ Manager(sdbusplus::bus::bus& bus, const std::string& jsonPath);
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - sdbusplus object
+ */
+ explicit Manager(sdbusplus::bus::bus& bus) :
+ Manager(bus, ASSOCIATIONS_FILE_PATH)
+ {
+ }
+
+ /**
+ * @brief Creates any association D-Bus interfaces required based on
+ * the JSON associations definition for the object path passed
+ * in.
+ *
+ * Called after PIM creates a new inventory D-Bus interface on objectPath.
+ *
+ * @param[in] objectPath - the D-Bus object path to check for associations
+ */
+ void createAssociations(const std::string& objectPath);
+
+ private:
+ /**
+ * @brief The sdbusplus bus object.
+ */
+ sdbusplus::bus::bus& _bus;
+
+ /**
+ * @brief The path to the associations JSON File.
+ */
+ const std::string _jsonFile;
+};
+
+} // namespace associations
+} // namespace manager
+} // namespace inventory
+} // namespace phosphor