summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2017-02-02 09:24:56 -0600
committerBrad Bishop <bradleyb@us.ibm.com>2017-02-03 00:35:51 -0500
commitdfa19092a1e1fd4cd1bc25238da9f147ca3c03e7 (patch)
tree5f4651c5cd6e9f99d653beed179613938e890f2f /tools
parent4d47bf0aaa864c3ca9af9ea8016b53cc1b2b7c6c (diff)
downloadsdbusplus-dfa19092a1e1fd4cd1bc25238da9f147ca3c03e7.tar.gz
sdbusplus-dfa19092a1e1fd4cd1bc25238da9f147ca3c03e7.zip
sdbus++: Add server method for get-property
Add a method to the server bindings that gets properties by looking up the name from a string. Change-Id: I304504ba20d6747afba27cd08f79bcc564c34a46 Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/sdbusplus/templates/interface.mako.server.cpp13
-rw-r--r--tools/sdbusplus/templates/interface.mako.server.hpp6
2 files changed, 19 insertions, 0 deletions
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp b/tools/sdbusplus/templates/interface.mako.server.cpp
index ca77ae1..14dfa01 100644
--- a/tools/sdbusplus/templates/interface.mako.server.cpp
+++ b/tools/sdbusplus/templates/interface.mako.server.cpp
@@ -160,6 +160,19 @@ val);
% endfor
}
+auto ${classname}::getPropertyByName(const std::string& name) ->
+ PropertiesVariant
+{
+ % for p in interface.properties:
+ if (name == "${p.name}")
+ {
+ return ${p.camelCase}();
+ }
+ % endfor
+
+ return PropertiesVariant();
+}
+
% endif
% for e in interface.enums:
diff --git a/tools/sdbusplus/templates/interface.mako.server.hpp b/tools/sdbusplus/templates/interface.mako.server.hpp
index ca45c66..c67f9b7 100644
--- a/tools/sdbusplus/templates/interface.mako.server.hpp
+++ b/tools/sdbusplus/templates/interface.mako.server.hpp
@@ -92,6 +92,12 @@ ${p.camelCase}(${p.cppTypeParam(interface.name)} value);
void setPropertyByName(const std::string& name,
const PropertiesVariant& val);
+ /** @brief Gets a property by name.
+ * @param[in] name - A string representation of the property name.
+ * @return - A variant containing the value of the property.
+ */
+ PropertiesVariant getPropertyByName(const std::string& name);
+
% endif
% for e in interface.enums:
/** @brief Convert a string to an appropriate enum value.
OpenPOWER on IntegriCloud