Add async_method_call to utility
Adding async_method_call in dbus utility gives us a place where we can
intercept method call requests from dbus to potentially add
logging/caching.
An example of logging is in the later commit:
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/78265/
We already do this for setProperty, this moves the method calls to
follow a similar pattern.
Tested: Redfish service validator passes.
Change-Id: I6d2c96e2b6b6a023ed2138106a55faebca161592
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index d1f4a84..4eedcbf 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -3,6 +3,7 @@
// SPDX-FileCopyrightText: Copyright 2018 Intel Corporation
#pragma once
+#include "async_resp.hpp"
#include "boost_formatters.hpp"
#include "dbus_singleton.hpp"
@@ -14,6 +15,7 @@
#include <cstddef>
#include <cstdint>
#include <functional>
+#include <memory>
#include <span>
#include <string>
#include <string_view>
@@ -99,6 +101,29 @@
std::function<void(const boost::system::error_code&,
const DBusPropertiesMap&)>&& callback);
+template <typename MessageHandler, typename... InputArgs>
+// NOLINTNEXTLINE(readability-identifier-naming)
+void async_method_call(MessageHandler&& handler, const std::string& service,
+ const std::string& objpath, const std::string& interf,
+ const std::string& method, const InputArgs&... a)
+{
+ crow::connections::systemBus->async_method_call(
+ std::forward<MessageHandler>(handler), service, objpath, interf, method,
+ a...);
+}
+
+template <typename MessageHandler, typename... InputArgs>
+// NOLINTNEXTLINE(readability-identifier-naming)
+void async_method_call(const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/,
+ MessageHandler&& handler, const std::string& service,
+ const std::string& objpath, const std::string& interf,
+ const std::string& method, const InputArgs&... a)
+{
+ crow::connections::systemBus->async_method_call(
+ std::forward<MessageHandler>(handler), service, objpath, interf, method,
+ a...);
+}
+
template <typename PropertyType>
void getProperty(const std::string& service, const std::string& objectPath,
const std::string& interface, const std::string& propertyName,