From 5a796e6683a3c8dba6be5d72ef7f7d4d8cdbfcae Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Fri, 19 Jan 2018 17:14:08 -0600 Subject: Get a property without service name lookup Expand on the current getProperty functions to allow a service name to be passed in so a mapper lookup is not necessary. Tested: A property value is read from a message where the service is given Change-Id: Ia0450163744c9f89a26a053ec2cfb44ae761426d Signed-off-by: Matthew Barth --- sdbusplus.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'sdbusplus.hpp') diff --git a/sdbusplus.hpp b/sdbusplus.hpp index 3fc9b9e..0c70b9c 100644 --- a/sdbusplus.hpp +++ b/sdbusplus.hpp @@ -245,6 +245,46 @@ class SDBusPlus property); } + /** @brief Get a property without mapper lookup. */ + template + static auto getProperty( + sdbusplus::bus::bus& bus, + const std::string& service, + const std::string& path, + const std::string& interface, + const std::string& property) + { + using namespace std::literals::string_literals; + + auto msg = callMethod( + bus, + service, + path, + "org.freedesktop.DBus.Properties"s, + "Get"s, + interface, + property); + sdbusplus::message::variant value; + msg.read(value); + return value.template get(); + } + + /** @brief Get a property without mapper lookup. */ + template + static auto getProperty( + const std::string& service, + const std::string& path, + const std::string& interface, + const std::string& property) + { + return getProperty( + getBus(), + service, + path, + interface, + property); + } + /** @brief Set a property with mapper lookup. */ template static void setProperty( -- cgit v1.2.1