Call method and return function
Add a function that calls a method and returns the response message
without checking for an error. Its up to the user of this function to
check if response.is_method_error() exists and handle accordingly.
Tested:
Method is called and raw response is returned
Change-Id: I6678a78d8cfb32d2d13dba7cb48719fd26eccebc
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index e977744..eb380cc 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -538,6 +538,27 @@
method,
std::forward<Args>(args)...);
}
+
+ /** @brief Invoke a method and return without checking for error. */
+ template <typename ...Args>
+ static auto callMethodAndReturn(
+ sdbusplus::bus::bus& bus,
+ const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method,
+ Args&& ... args)
+ {
+ auto reqMsg = bus.new_method_call(
+ busName.c_str(),
+ path.c_str(),
+ interface.c_str(),
+ method.c_str());
+ reqMsg.append(std::forward<Args>(args)...);
+ auto respMsg = bus.call(reqMsg);
+
+ return respMsg;
+ }
};
} // namespace util