diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-10-31 14:17:23 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-11-14 11:14:53 -0600 |
commit | df1b7cfc395e2e48c9924186a6127d06a77541ea (patch) | |
tree | f2541fe5c5fc198b9f83fad3fb2626b448bcf229 /src/sdbusplus.hpp | |
parent | 56fd833d55f62962f7d4c7c8421006cab7b98409 (diff) | |
download | phosphor-dbus-monitor-df1b7cfc395e2e48c9924186a6127d06a77541ea.tar.gz phosphor-dbus-monitor-df1b7cfc395e2e48c9924186a6127d06a77541ea.zip |
Add getBusName() utility function to SDBusPlus
Add a function to SDBusPlus to get the D-Bus bus
name for an object path and interface.
Change-Id: I7d7a533c7430fcf42e1e0f6a21a2453e6c8197ea
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'src/sdbusplus.hpp')
-rw-r--r-- | src/sdbusplus.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp index aba5a36..d62a5d4 100644 --- a/src/sdbusplus.hpp +++ b/src/sdbusplus.hpp @@ -3,6 +3,7 @@ #include <sdbusplus/bus.hpp> #include <sdbusplus/message.hpp> #include <sdbusplus/bus/match.hpp> +#include "data_types.hpp" struct Loop; @@ -104,6 +105,29 @@ class SDBusPlus callback); } + /** @brief Look up the bus name for a path and interface */ + static auto getBusName( + const std::string& path, + const std::string& interface) + { + std::vector<std::string> interfaces{interface}; + + auto object = callMethodAndRead<GetObject>( + MAPPER_BUSNAME, + MAPPER_PATH, + MAPPER_INTERFACE, + "GetObject", + path, + interfaces); + + std::string name; + if (!object.empty()) + { + name = object.begin()->first; + } + return name; + } + friend Loop; }; |