Support multiple D-Bus interfaces in getSubTree()
The utility function getSubTree() only allows a single D-Bus interface
to be specified.
This does not match the corresponding GetSubTree D-Bus method, which
allows multiple D-Bus interfaces to be specified.
Add a getSubTree() overload that accepts multiple D-Bus interfaces.
Tested:
* Existing getSubTree() function
* Test where it is successful
* Test where it fails due to a D-Bus error
* New getSubTree() function
* Test where zero interfaces are specified
* Test where one interface is specified
* Test where multiple interfaces are specified
* Test where it is successful
* Test where it fails due to a D-Bus error
Change-Id: I56e124c13bec633f7a3af80ff6d5b2014454bfb8
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/utility.hpp b/utility.hpp
index 043c3c0..ad6be99 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -8,6 +8,7 @@
#include <sdbusplus/bus.hpp>
#include <string>
+#include <vector>
namespace phosphor
{
@@ -130,6 +131,24 @@
DbusSubtree getSubTree(sdbusplus::bus_t& bus, const std::string& path,
const std::string& interface, int32_t depth);
+/** @brief Get subtree from the object mapper.
+ *
+ * Helper function to find objects, services, and interfaces.
+ * See:
+ * https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md
+ *
+ * @param[in] bus - The D-Bus object.
+ * @param[in] path - The root of the tree to search.
+ * @param[in] interfaces - Interfaces in the subtree to search for.
+ * @param[in] depth - The number of path elements to descend.
+ *
+ * @return DbusSubtree - Map of object paths to a map of service names to their
+ * interfaces.
+ */
+DbusSubtree getSubTree(sdbusplus::bus_t& bus, const std::string& path,
+ const std::vector<std::string>& interfaces,
+ int32_t depth);
+
/** @brief GetAssociatedSubTreePaths wrapper from the object mapper.
*
* Helper function to find object paths that implement a certain