From 7c48d10d85916352563e4229c52bcd357563fb49 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Wed, 9 May 2018 14:52:36 -0500 Subject: 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 --- sdbusplus.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sdbusplus.hpp') diff --git a/sdbusplus.hpp b/sdbusplus.hpp index e977744..eb380cc 100644 --- a/sdbusplus.hpp +++ b/sdbusplus.hpp @@ -538,6 +538,27 @@ class SDBusPlus method, std::forward(args)...); } + + /** @brief Invoke a method and return without checking for error. */ + template + 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)...); + auto respMsg = bus.call(reqMsg); + + return respMsg; + } }; } // namespace util -- cgit v1.2.1