diff options
-rw-r--r-- | sdbusplus.hpp | 77 |
1 files changed, 77 insertions, 0 deletions
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 <typename Variant> + 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 <typename Variant> + static auto getPropertyVariant( + const std::string& path, + const std::string& interface, + const std::string& property) + { + return getPropertyVariant<Variant>( + getBus(), + path, + interface, + property); + } + /** @brief Get a property without mapper lookup. */ template <typename Property> static auto getProperty( @@ -285,6 +322,46 @@ class SDBusPlus property); } + /** @brief Get a property variant without mapper lookup. */ + template <typename Variant> + 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 <typename Variant> + static auto getPropertyVariant( + const std::string& service, + const std::string& path, + const std::string& interface, + const std::string& property) + { + return getPropertyVariant<Variant>( + getBus(), + service, + path, + interface, + property); + } + /** @brief Set a property with mapper lookup. */ template <typename Property> static void setProperty( |