Support the new association defs interface
An xyz.openbmc_project version of the org.openbmc_project.Associations
interface was just created:
xyz.openbmc_project.Association.Definitions
property: Associations
Support this interface as well as the original org.openbmc one.
Change-Id: Idc5a0e5afab51ec96f18a2759446707146b077d1
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/src/processing.hpp b/src/processing.hpp
index d5ed2b4..475133d 100644
--- a/src/processing.hpp
+++ b/src/processing.hpp
@@ -4,13 +4,44 @@
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
+#include <cassert>
#include <string>
/** @brief Define white list and black list data structure */
using WhiteBlackList = boost::container::flat_set<std::string>;
-/** @brief Dbus interface which contains org.openbmc Associations */
-constexpr const char* ASSOCIATIONS_INTERFACE = "org.openbmc.Associations";
+/** @brief The old associations definitions interface */
+constexpr const char* orgOpenBMCAssocDefsInterface = "org.openbmc.Associations";
+/** @brief The new associations definitions interface */
+constexpr const char* assocDefsInterface =
+ "xyz.openbmc_project.Association.Definitions";
+
+/** @brief Says if the interface is the association definition interface.
+ * Supports either the new or old interface.
+ *
+ * @param[in] iface - the interface to check
+ * @return bool - if the interface is one of the association definition
+ * ones.
+ */
+inline bool isAssocDefIface(std::string_view iface)
+{
+ return (iface == assocDefsInterface) ||
+ (iface == orgOpenBMCAssocDefsInterface);
+}
+
+/** @brief Returns the property name used by the defs iface.
+ *
+ * The old interface broke convention and used a lower case property
+ * name. This was resolved with the new interface.
+ *
+ * @param[in] iface - the interface to check
+ * @return std::string - the property name
+ */
+inline std::string getAssocDefPropName(std::string_view iface)
+{
+ assert(isAssocDefIface(iface));
+ return (iface == assocDefsInterface) ? "Associations" : "associations";
+}
/** @brief interface_map_type is the underlying datastructure the mapper uses.
*