summaryrefslogtreecommitdiffstats
path: root/sdbusplus.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-05-03 16:50:47 -0500
committerMatthew Barth <msbarth@us.ibm.com>2018-05-03 16:55:26 -0500
commit7311c39440a88c6dcf3e64e5ee05900488721fbc (patch)
treee82cca3127bd9b4a5faa65407bf7f290289de563 /sdbusplus.hpp
parent30abbef89b0c39d88c8f7704bcfffceac7963fd2 (diff)
downloadphosphor-fan-presence-7311c39440a88c6dcf3e64e5ee05900488721fbc.tar.gz
phosphor-fan-presence-7311c39440a88c6dcf3e64e5ee05900488721fbc.zip
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 <msbarth@us.ibm.com>
Diffstat (limited to 'sdbusplus.hpp')
-rw-r--r--sdbusplus.hpp77
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(
OpenPOWER on IntegriCloud