Add the GetObject method to dbus_utility

There are currently many files that use the GetObject method.
Since they are a general method, they are defined in the
dbus_utility.hpp file and refactors them.

Tested: Built bmcweb successfully and Validator passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If2af77294389b023b611987252ee6149906fcd25
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index c7fda6d..c9143de 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -175,5 +175,21 @@
         interfaces);
 }
 
+inline void
+    getDbusObject(const std::string& path,
+                  std::span<const std::string_view> interfaces,
+                  std::function<void(const boost::system::error_code&,
+                                     const MapperGetObject&)>&& callback)
+{
+    crow::connections::systemBus->async_method_call(
+        [callback{std::move(callback)}](const boost::system::error_code& ec,
+                                        const MapperGetObject& object) {
+        callback(ec, object);
+        },
+        "xyz.openbmc_project.ObjectMapper",
+        "/xyz/openbmc_project/object_mapper",
+        "xyz.openbmc_project.ObjectMapper", "GetObject", path, interfaces);
+}
+
 } // namespace utility
 } // namespace dbus