dbus_utility: Support new ObjectMapper methods
The new ObjectMapper methods are added as part of
https://gerrit.openbmc.org/c/openbmc/phosphor-objmgr/+/57822
- GetAssociatedSubTree
- GetAssociatedSubTreePaths
The two methods are meant to be used to replace places where two dbus
calls are used to get subtree and then get associated objects.
Change-Id: I80a7ea935700a1ac5aebe6271f242aa103cc3d59
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index 73952a2..b278882 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -189,6 +189,42 @@
interfaces);
}
+inline void getAssociatedSubTree(
+ const sdbusplus::message::object_path& associatedPath,
+ const sdbusplus::message::object_path& path, int32_t depth,
+ std::span<const std::string_view> interfaces,
+ std::function<void(const boost::system::error_code&,
+ const MapperGetSubTreeResponse&)>&& callback)
+{
+ crow::connections::systemBus->async_method_call(
+ [callback{std::move(callback)}](
+ const boost::system::error_code& ec,
+ const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTree",
+ associatedPath, path, depth, interfaces);
+}
+
+inline void getAssociatedSubTreePaths(
+ const sdbusplus::message::object_path& associatedPath,
+ const sdbusplus::message::object_path& path, int32_t depth,
+ std::span<const std::string_view> interfaces,
+ std::function<void(const boost::system::error_code&,
+ const MapperGetSubTreePathsResponse&)>&& callback)
+{
+ crow::connections::systemBus->async_method_call(
+ [callback{std::move(callback)}](
+ const boost::system::error_code& ec,
+ const MapperGetSubTreePathsResponse& subtreePaths) {
+ callback(ec, subtreePaths);
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreePaths",
+ associatedPath, path, depth, interfaces);
+}
+
inline void
getDbusObject(const std::string& path,
std::span<const std::string_view> interfaces,