summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-05-09 14:52:36 -0500
committerMatthew Barth <msbarth@linux.ibm.com>2018-05-17 17:09:42 +0000
commit7c48d10d85916352563e4229c52bcd357563fb49 (patch)
tree112d5cdb4c158a50dfcd976688d2810c28ae62d3
parent1061cba14167d88e9901e6ea50ae58854891ea8e (diff)
downloadphosphor-fan-presence-7c48d10d85916352563e4229c52bcd357563fb49.tar.gz
phosphor-fan-presence-7c48d10d85916352563e4229c52bcd357563fb49.zip
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>
-rw-r--r--sdbusplus.hpp21
1 files changed, 21 insertions, 0 deletions
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>(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
OpenPOWER on IntegriCloud