Move the getSubTree method to utils
Since the getSubTree method is a generic method that users may use
anywhere, It is better to move this method to utils.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ib6e1367b9885dac38a7ba6b63329977436e70c26
diff --git a/utils.hpp b/utils.hpp
index 6f2fc62..dd81314 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -5,6 +5,8 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
+#include <vector>
+
namespace phosphor
{
namespace time
@@ -12,6 +14,13 @@
namespace utils
{
+using Path = std::string;
+using Service = std::string;
+using Interface = std::string;
+using Interfaces = std::vector<Interface>;
+using MapperResponse =
+ std::vector<std::pair<Path, std::vector<std::pair<Service, Interfaces>>>>;
+
/** @brief The template function to get property from the requested dbus path
*
* @param[in] bus - The Dbus bus object
@@ -57,6 +66,20 @@
std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface);
+/** @brief Get sub tree from root, depth and interfaces
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] root - The root of the tree to search
+ * @param[in] interfaces - All interfaces in the subtree to search for
+ * @param[in] depth - The number of path elements to descend
+ *
+ * @return The name of the service
+ *
+ * @throw sdbusplus::exception_t when it fails
+ */
+MapperResponse getSubTree(sdbusplus::bus_t& bus, const std::string& root,
+ const Interfaces& interfaces, int32_t depth);
+
/** @brief Convert a string to enum Mode
*
* Convert the time mode string to enum.