Add GetSubTree method for single interface

Perform a GetSubTree mapper call and return the mapper response
structure as is for a single interface over a given path subtree depth.

Tested:
    Returned subtree structure matches mapper structure for an interface
    Returned subtree data matches mapper data for an interface

Change-Id: If6b66433a331ac20633ac99c458eb5edb653bff2
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 1efe54d..3fc9b9e 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -128,6 +128,44 @@
                     std::forward<Args>(args)...);
         }
 
+        /** @brief Get subtree from the mapper. */
+        static auto getSubTree(
+            sdbusplus::bus::bus& bus,
+            const std::string& path,
+            const std::string& interface,
+            int32_t depth)
+        {
+            using namespace std::literals::string_literals;
+
+            using Path = std::string;
+            using Intf = std::string;
+            using Serv = std::string;
+            using Intfs = std::vector<Intf>;
+            using Objects = std::map<Path, std::map<Serv, Intfs>>;
+            Intfs intfs = {interface};
+
+            auto mapperResp = callMethodAndRead<Objects>(
+                    bus,
+                    "xyz.openbmc_project.ObjectMapper"s,
+                    "/xyz/openbmc_project/object_mapper"s,
+                    "xyz.openbmc_project.ObjectMapper"s,
+                    "GetSubTree"s,
+                    path,
+                    depth,
+                    intfs);
+
+            if (mapperResp.empty())
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                        "Empty response from mapper GetSubTree",
+                        phosphor::logging::entry("SUBTREE=%s", path.c_str()),
+                        phosphor::logging::entry(
+                                "INTERFACE=%s", interface.c_str()),
+                        phosphor::logging::entry("DEPTH=%u", depth));
+                phosphor::logging::elog<detail::errors::InternalFailure>();
+            }
+            return mapperResp;
+        }
 
         /** @brief Get service from the mapper. */
         static auto getService(