Add getSubtreePaths utility functions

Added a getSubTreePaths utility function that can return the
subtree dbus paths that implement the particular dbus interface.

Change-Id: Ifb8f6d571bcb2291ca3a47f285ebf46261646496
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/common/utils.cpp b/common/utils.cpp
index e9b2c68..72104a5 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -448,6 +448,22 @@
     return response;
 }
 
+GetSubTreePathsResponse DBusHandler::getSubTreePaths(
+    const std::string& objectPath, int depth,
+    const std::vector<std::string>& ifaceList) const
+{
+    std::vector<std::string> paths;
+    auto& bus = pldm::utils::DBusHandler::getBus();
+    auto method = bus.new_method_call(
+        ObjectMapper::default_service, ObjectMapper::instance_path,
+        ObjectMapper::interface, "GetSubTreePaths");
+    method.append(objectPath, depth, ifaceList);
+    auto reply = bus.call(method, dbusTimeout);
+
+    reply.read(paths);
+    return paths;
+}
+
 void reportError(const char* errorMsg)
 {
     auto& bus = pldm::utils::DBusHandler::getBus();
diff --git a/common/utils.hpp b/common/utils.hpp
index 10038b4..28f11d6 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -198,6 +198,7 @@
 using Interfaces = std::vector<std::string>;
 using MapperServiceMap = std::vector<std::pair<ServiceName, Interfaces>>;
 using GetSubTreeResponse = std::vector<std::pair<ObjectPath, MapperServiceMap>>;
+using GetSubTreePathsResponse = std::vector<std::string>;
 using PropertyMap = std::map<std::string, PropertyValue>;
 using InterfaceMap = std::map<std::string, PropertyMap>;
 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
@@ -216,6 +217,10 @@
         getSubtree(const std::string& path, int depth,
                    const std::vector<std::string>& ifaceList) const = 0;
 
+    virtual GetSubTreePathsResponse
+        getSubTreePaths(const std::string& objectPath, int depth,
+                        const std::vector<std::string>& ifaceList) const = 0;
+
     virtual void setDbusProperty(const DBusMapping& dBusMap,
                                  const PropertyValue& value) const = 0;
 
@@ -276,6 +281,19 @@
         getSubtree(const std::string& path, int depth,
                    const std::vector<std::string>& ifaceList) const override;
 
+    /** @brief Get Subtree path response from the mapper
+     *
+     *  @param[in] path - DBUS object path
+     *  @param[in] depth - Search depth
+     *  @param[in] ifaceList - list of the interface that are being
+     *                         queried from the mapper
+     *
+     *  @return std::vector<std::string> vector of subtree paths
+     */
+    GetSubTreePathsResponse getSubTreePaths(
+        const std::string& objectPath, int depth,
+        const std::vector<std::string>& ifaceList) const override;
+
     /** @brief Get property(type: variant) from the requested dbus
      *
      *  @param[in] objPath - The Dbus object path