summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-01-19 17:14:08 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-12 10:29:43 -0500
commit5a796e6683a3c8dba6be5d72ef7f7d4d8cdbfcae (patch)
tree0d8e89136f1fb442bee9d97c56d1e9ace643f6e0
parenta603ed010ad58e87711793a1278e3b071ad1d2fc (diff)
downloadphosphor-fan-presence-5a796e6683a3c8dba6be5d72ef7f7d4d8cdbfcae.tar.gz
phosphor-fan-presence-5a796e6683a3c8dba6be5d72ef7f7d4d8cdbfcae.zip
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 <msbarth@us.ibm.com>
-rw-r--r--sdbusplus.hpp40
1 files changed, 40 insertions, 0 deletions
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 <typename Property>
+ 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<Property> value;
+ msg.read(value);
+ return value.template get<Property>();
+ }
+
+ /** @brief Get a property without mapper lookup. */
+ template <typename Property>
+ static auto getProperty(
+ const std::string& service,
+ const std::string& path,
+ const std::string& interface,
+ const std::string& property)
+ {
+ return getProperty<Property>(
+ getBus(),
+ service,
+ path,
+ interface,
+ property);
+ }
+
/** @brief Set a property with mapper lookup. */
template <typename Property>
static void setProperty(
OpenPOWER on IntegriCloud