diff options
| author | Patrick Williams <patrick@stwcx.xyz> | 2017-02-01 23:16:23 -0600 |
|---|---|---|
| committer | Brad Bishop <bradleyb@us.ibm.com> | 2017-02-03 00:35:43 -0500 |
| commit | 4d47bf0aaa864c3ca9af9ea8016b53cc1b2b7c6c (patch) | |
| tree | ec329fff5b01535757608c8c3272d8ca0daa18bf | |
| parent | 9fa855206cb1932951b3031a7d1b3c057df6296b (diff) | |
| download | sdbusplus-4d47bf0aaa864c3ca9af9ea8016b53cc1b2b7c6c.tar.gz sdbusplus-4d47bf0aaa864c3ca9af9ea8016b53cc1b2b7c6c.zip | |
sdbus++: Add server constructor from property-map
Add a constructor that takes a map of property-names to
values and initializes all properties in the map with those
values.
Change-Id: Id0eaa2ec43aed490719d12537e75c1278d290013
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
| -rw-r--r-- | tools/sdbusplus/templates/interface.mako.server.cpp | 12 | ||||
| -rw-r--r-- | tools/sdbusplus/templates/interface.mako.server.hpp | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp b/tools/sdbusplus/templates/interface.mako.server.cpp index dceeac4..ca77ae1 100644 --- a/tools/sdbusplus/templates/interface.mako.server.cpp +++ b/tools/sdbusplus/templates/interface.mako.server.cpp @@ -27,6 +27,18 @@ ${classname}::${classname}(bus::bus& bus, const char* path) { } + % if interface.properties: +${classname}::${classname}(bus::bus& bus, const char* path, + const std::map<std::string, PropertiesVariant>& vals) + : ${classname}(bus, path) +{ + for (const auto& v : vals) + { + setPropertyByName(v.first, v.second); + } +} + + % endif % for m in interface.methods: ${ m.cpp_prototype(loader, interface=interface, ptype='callback-cpp') } % endfor diff --git a/tools/sdbusplus/templates/interface.mako.server.hpp b/tools/sdbusplus/templates/interface.mako.server.hpp index 440fcce..ca45c66 100644 --- a/tools/sdbusplus/templates/interface.mako.server.hpp +++ b/tools/sdbusplus/templates/interface.mako.server.hpp @@ -57,6 +57,16 @@ class ${classname} using PropertiesVariant = sdbusplus::message::variant< ${",\n ".join(setOfPropertyTypes())}>; + /** @brief Constructor to initialize the object from a map of + * properties. + * + * @param[in] bus - Bus to attach to. + * @param[in] path - Path to attach at. + * @param[in] vals - Map of property name to value for initalization. + */ + ${classname}(bus::bus& bus, const char* path, + const std::map<std::string, PropertiesVariant>& vals); + % endif % for m in interface.methods: ${ m.cpp_prototype(loader, interface=interface, ptype='header') } |

