Add a phosphor::power::util getSubTree helper
Adding a helper function to do the GetSubTree method call on the object
mapper.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Iaac9723d6e1086b873ad6b260daf46a8cfa875c3
diff --git a/utility.cpp b/utility.cpp
index 7fdd6b2..cec9d8b 100644
--- a/utility.cpp
+++ b/utility.cpp
@@ -63,6 +63,22 @@
return response.begin()->first;
}
+DbusSubtree getSubTree(sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface, int32_t depth)
+{
+ auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetSubTree");
+ mapperCall.append(path);
+ mapperCall.append(depth);
+ mapperCall.append(std::vector<std::string>({interface}));
+
+ auto reply = bus.call(mapperCall);
+
+ DbusSubtree response;
+ reply.read(response);
+ return response;
+}
+
json loadJSONFromFile(const char* path)
{
std::ifstream ifs(path);