From eca94df80661480e703b43e4adfb90363c415e66 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Fri, 19 Jan 2018 16:42:49 -0600 Subject: 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 --- sdbusplus.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sdbusplus.hpp b/sdbusplus.hpp index 1efe54d..3fc9b9e 100644 --- a/sdbusplus.hpp +++ b/sdbusplus.hpp @@ -128,6 +128,44 @@ class SDBusPlus std::forward(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; + using Objects = std::map>; + Intfs intfs = {interface}; + + auto mapperResp = callMethodAndRead( + 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( + "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(); + } + return mapperResp; + } /** @brief Get service from the mapper. */ static auto getService( -- cgit v1.2.1