Method support
Add support for a method callback. The method callback enables
arbitrary DBus method calls. A sample use case could be
starting a systemd unit via the sytemd DBus API.
Change-Id: If25131d11497c82f862ae1f47da066c5fd8b2e2e
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index 7dbf44d..8afb8b5 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -30,6 +30,28 @@
}
public:
+ /** @brief Invoke a method; ignore reply. */
+ template <typename ...Args>
+ static void callMethodNoReply(
+ const std::string& busName,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& method,
+ Args&& ... args)
+ {
+ auto reqMsg = getBus().new_method_call(
+ busName.c_str(),
+ path.c_str(),
+ interface.c_str(),
+ method.c_str());
+ reqMsg.append(std::forward<Args>(args)...);
+ getBus().call_noreply(reqMsg);
+
+ // TODO: openbmc/openbmc#1719
+ // invoke these methods async, with a callback
+ // handler that checks for errors and logs.
+ }
+
/** @brief Invoke a method. */
template <typename ...Args>
static auto callMethod(