Load the associations definitions
Parse the JSON file to load in the _associations
data structures. Any failures will cause an exception
to be thrown that will crash the app.
The JSON looks like:
[
{
"path": "The relative path of the inventory object to create the
org.openbmc.Associations interface on."
"endpoints":
[
{
"types":
{
"fType": "The forward association type."
"rType": "The reverse association type."
},
"paths":
[
"The list of association endpoints for this
inventory path and association type."
]
}
]
}
]
Change-Id: I098fdc607f0c3ab2861f9b33e3e0d46e4989bd7a
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/association_manager.hpp b/association_manager.hpp
index 1aff7e0..0196c36 100644
--- a/association_manager.hpp
+++ b/association_manager.hpp
@@ -13,6 +13,17 @@
namespace associations
{
+static constexpr auto forwardTypePos = 0;
+static constexpr auto reverseTypePos = 1;
+using Types = std::tuple<std::string, std::string>;
+using Paths = std::vector<std::string>;
+
+static constexpr auto typesPos = 0;
+static constexpr auto pathsPos = 1;
+using EndpointsEntry = std::vector<std::tuple<Types, Paths>>;
+
+using AssociationMap = std::map<std::string, EndpointsEntry>;
+
/**
* @class Manager
*
@@ -66,8 +77,33 @@
*/
void createAssociations(const std::string& objectPath);
+ /**
+ * @brief Returned the association configuration.
+ * Used for testing.
+ *
+ * @return AssociationMap& - the association config
+ */
+ const AssociationMap& getAssociationsConfig()
+ {
+ return _associations;
+ }
+
private:
/**
+ * @brief Loads the association YAML into the _associations data
+ * structure. This file is optional, so if it doesn't exist
+ * it will just not load anything.
+ */
+ void load();
+
+ /**
+ * @brief The map of association data that is loaded from its
+ * JSON definition. Association D-Bus objects will be
+ * created from this data.
+ */
+ AssociationMap _associations;
+
+ /**
* @brief The sdbusplus bus object.
*/
sdbusplus::bus::bus& _bus;