interface: add signal support
Change-Id: Ice572b6794e7cb2426a2e86b7bb92ca3d0ac7ae1
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/sdbusplus/message.hpp b/sdbusplus/message.hpp
index 74e0cdd..053cd61 100644
--- a/sdbusplus/message.hpp
+++ b/sdbusplus/message.hpp
@@ -137,6 +137,9 @@
sd_bus_send(b, this->get(), nullptr);
}
+ /** @brief Perform a 'signal-send' call. */
+ void signal_send() { method_return(); }
+
friend struct sdbusplus::bus::bus;
private:
diff --git a/sdbusplus/server/interface.hpp b/sdbusplus/server/interface.hpp
index d730e07..e3a2059 100644
--- a/sdbusplus/server/interface.hpp
+++ b/sdbusplus/server/interface.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <string>
#include <systemd/sd-bus.h>
#include <sdbusplus/slot.hpp>
#include <sdbusplus/vtable.hpp>
@@ -58,16 +59,34 @@
const char* path,
const char* interf,
const sdbusplus::vtable::vtable_t* vtable,
- void* context) : _slot(nullptr)
+ void* context) :
+ _bus(sd_bus_ref(bus.get())), _path(path), _interf(interf),
+ _slot(nullptr)
{
sd_bus_slot* slot = nullptr;
- sd_bus_add_object_vtable(bus.get(), &slot, path, interf,
- vtable, context);
+ sd_bus_add_object_vtable(_bus.get(), &slot, _path.c_str(),
+ _interf.c_str(), vtable, context);
_slot = decltype(_slot){slot};
+
}
+ /** @brief Create a new signal message.
+ *
+ * @param[in] member - The signal name to create.
+ */
+ auto new_signal(const char* member)
+ {
+ return _bus.new_signal(_path.c_str(), _interf.c_str(), member);
+ }
+
+ bus::bus& bus() { return _bus; }
+ const std::string& path() { return _path; }
+
private:
+ bus::bus _bus;
+ std::string _path;
+ std::string _interf;
slot::slot _slot;
};