Move common types into a common header
Upcoming commits will have code that references some of these
types in more files so it makes sense to have them in a common
place.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I92adbefdd4bcfdb5d8d7e30b7fdf0fa03c739d2a
diff --git a/src/associations.hpp b/src/associations.hpp
index 91a9fcd..73fc2e5 100644
--- a/src/associations.hpp
+++ b/src/associations.hpp
@@ -1,55 +1,10 @@
#pragma once
-#include <boost/container/flat_map.hpp>
-#include <boost/container/flat_set.hpp>
-#include <memory>
-#include <sdbusplus/asio/object_server.hpp>
-#include <string>
-#include <tuple>
-#include <vector>
+#include "types.hpp"
constexpr const char* XYZ_ASSOCIATION_INTERFACE =
"xyz.openbmc_project.Association";
-// Associations and some metadata are stored in associationInterfaces.
-// The fields are:
-// * ifacePos - holds the D-Bus interface object
-// * endpointsPos - holds the endpoints array that shadows the property
-static constexpr auto ifacePos = 0;
-static constexpr auto endpointsPos = 1;
-using Endpoints = std::vector<std::string>;
-
-// map[interface path: tuple[dbus_interface,vector[endpoint paths]]]
-using AssociationInterfaces = boost::container::flat_map<
- std::string,
- std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>>;
-
-// The associationOwners map contains information about creators of
-// associations, so that when a org.openbmc.Association interface is
-// removed or its 'associations' property is changed, the mapper owned
-// association objects can be correctly handled. It is a map of the
-// object path of the org.openbmc.Association owner to a map of the
-// service the path is owned by, to a map of the association objects to
-// their endpoint paths:
-// map[ownerPath : map[service : map[assocPath : [endpoint paths]]]
-// For example:
-// [/logging/entry/1 :
-// [xyz.openbmc_project.Logging :
-// [/logging/entry/1/callout : [/system/cpu0],
-// /system/cpu0/fault : [/logging/entry/1]]]]
-
-using AssociationPaths =
- boost::container::flat_map<std::string,
- boost::container::flat_set<std::string>>;
-
-using AssociationOwnersType = boost::container::flat_map<
- std::string, boost::container::flat_map<std::string, AssociationPaths>>;
-
-// Store the contents of the associations property on the interface
-// For example:
-// ["inventory", "activation", "/xyz/openbmc_project/inventory/system/chassis"]
-using Association = std::tuple<std::string, std::string, std::string>;
-
/** @brief Remove input association
*
* @param[in] sourcePath - Path of the object that contains the
diff --git a/src/main.cpp b/src/main.cpp
index e6ea2bb..1ed5435 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,7 @@
#include "associations.hpp"
#include "processing.hpp"
#include "src/argument.hpp"
+#include "types.hpp"
#include <tinyxml2.h>
diff --git a/src/processing.hpp b/src/processing.hpp
index 475133d..e37f279 100644
--- a/src/processing.hpp
+++ b/src/processing.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "associations.hpp"
+#include "types.hpp"
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
@@ -43,17 +44,6 @@
return (iface == assocDefsInterface) ? "Associations" : "associations";
}
-/** @brief interface_map_type is the underlying datastructure the mapper uses.
- *
- * The 3 levels of map are
- * object paths
- * connection names
- * interface names
- */
-using interface_map_type = boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, boost::container::flat_set<std::string>>>;
-
/** @brief InterfacesAdded represents the dbus data from the signal
*
* There are 2 pairs
diff --git a/src/types.hpp b/src/types.hpp
new file mode 100644
index 0000000..8415cf3
--- /dev/null
+++ b/src/types.hpp
@@ -0,0 +1,64 @@
+#pragma once
+
+#include <boost/container/flat_map.hpp>
+#include <boost/container/flat_set.hpp>
+#include <memory>
+#include <sdbusplus/asio/object_server.hpp>
+#include <string>
+#include <tuple>
+#include <vector>
+
+/** @brief interface_map_type is the underlying datastructure the mapper uses.
+ *
+ * The 3 levels of map are
+ * object paths
+ * connection names
+ * interface names
+ */
+using interface_map_type = boost::container::flat_map<
+ std::string, boost::container::flat_map<
+ std::string, boost::container::flat_set<std::string>>>;
+
+/**
+ * Associations and some metadata are stored in associationInterfaces.
+ * The fields are:
+ * * ifacePos - holds the D-Bus interface object
+ * * endpointsPos - holds the endpoints array that shadows the property
+ */
+static constexpr auto ifacePos = 0;
+static constexpr auto endpointsPos = 1;
+using Endpoints = std::vector<std::string>;
+
+// map[interface path: tuple[dbus_interface,vector[endpoint paths]]]
+using AssociationInterfaces = boost::container::flat_map<
+ std::string,
+ std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>>;
+
+/**
+ * The associationOwners map contains information about creators of
+ * associations, so that when a org.openbmc.Association interface is
+ * removed or its 'associations' property is changed, the mapper owned
+ * association objects can be correctly handled. It is a map of the
+ * object path of the org.openbmc.Association owner to a map of the
+ * service the path is owned by, to a map of the association objects to
+ * their endpoint paths:
+ * map[ownerPath : map[service : map[assocPath : [endpoint paths]]]
+ * For example:
+ * [/logging/entry/1 :
+ * [xyz.openbmc_project.Logging :
+ * [/logging/entry/1/callout : [/system/cpu0],
+ * /system/cpu0/fault : [/logging/entry/1]]]]
+ */
+using AssociationPaths =
+ boost::container::flat_map<std::string,
+ boost::container::flat_set<std::string>>;
+
+using AssociationOwnersType = boost::container::flat_map<
+ std::string, boost::container::flat_map<std::string, AssociationPaths>>;
+
+/**
+ * Store the contents of the associations property on the interface
+ * For example:
+ * ["inventory", "activation", "/xyz/openbmc_project/inventory/system/chassis"]
+ */
+using Association = std::tuple<std::string, std::string, std::string>;