From 7311c39440a88c6dcf3e64e5ee05900488721fbc Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Thu, 3 May 2018 16:50:47 -0500 Subject: Add methods to return property variant Create methods to return a property variant for use where the overloaded comparison operations are needed against a property value stored as a variant. Tested: A property is looked up and returned as the given variant type Change-Id: Iab557781a3ab9e33d3595ad69db5544a25efe2eb Signed-off-by: Matthew Barth --- sdbusplus.hpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'sdbusplus.hpp') diff --git a/sdbusplus.hpp b/sdbusplus.hpp index 0c70b9c..454fde8 100644 --- a/sdbusplus.hpp +++ b/sdbusplus.hpp @@ -245,6 +245,43 @@ class SDBusPlus property); } + /** @brief Get a property variant with mapper lookup. */ + template + static auto getPropertyVariant( + sdbusplus::bus::bus& bus, + const std::string& path, + const std::string& interface, + const std::string& property) + { + using namespace std::literals::string_literals; + + auto msg = callMethod( + bus, + getService(bus, path, interface), + path, + "org.freedesktop.DBus.Properties"s, + "Get"s, + interface, + property); + Variant value; + msg.read(value); + return value; + } + + /** @brief Get a property variant with mapper lookup. */ + template + static auto getPropertyVariant( + const std::string& path, + const std::string& interface, + const std::string& property) + { + return getPropertyVariant( + getBus(), + path, + interface, + property); + } + /** @brief Get a property without mapper lookup. */ template static auto getProperty( @@ -285,6 +322,46 @@ class SDBusPlus property); } + /** @brief Get a property variant without mapper lookup. */ + template + static auto getPropertyVariant( + 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); + Variant value; + msg.read(value); + return value; + } + + /** @brief Get a property variant without mapper lookup. */ + template + static auto getPropertyVariant( + const std::string& service, + const std::string& path, + const std::string& interface, + const std::string& property) + { + return getPropertyVariant( + getBus(), + service, + path, + interface, + property); + } + /** @brief Set a property with mapper lookup. */ template static void setProperty( -- cgit v1.2.1