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>
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 3fc9b9e..0c70b9c 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -245,6 +245,46 @@
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(