bus: Add get_unique_name method
The dbus bus unique name will be used for generating a unique hash id.
Change-Id: I275acdcc89ce7e459e87dfdca2b395ba7fa00f05
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/sdbusplus/bus.hpp b/sdbusplus/bus.hpp
index 07ce3aa..d0536d7 100644
--- a/sdbusplus/bus.hpp
+++ b/sdbusplus/bus.hpp
@@ -167,6 +167,17 @@
sd_bus_call(_bus.get(), m.get(), timeout_us, nullptr, nullptr);
}
+ /** @brief Get the bus unique name. Ex: ":1.11".
+ *
+ * @return The bus unique name.
+ */
+ auto get_unique_name()
+ {
+ const char* unique = nullptr;
+ sd_bus_get_unique_name(_bus.get(), &unique);
+ return std::string(unique);
+ }
+
friend struct server::interface::interface;
friend struct server::manager::manager;
template<class... Args> friend struct server::object::object;