diff options
| author | Patrick Williams <patrick@stwcx.xyz> | 2016-10-17 14:43:54 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2016-10-20 16:35:51 -0500 |
| commit | adc16824e352334bc946248106bfeb972c22e456 (patch) | |
| tree | 450c98a8e1ba951cbe5bfd2178a199d988bd01dd | |
| parent | 05aab8ba1f881e91cffc342c77811cf5bda62f28 (diff) | |
| download | sdbusplus-adc16824e352334bc946248106bfeb972c22e456.tar.gz sdbusplus-adc16824e352334bc946248106bfeb972c22e456.zip | |
sdbus++: hook interface into server bindings
sdbusplus::server::interface class is used to register an
interface on the dbus. Utilize this in the generated server
bindings by containing an instance of 'interface' and creating
a proper constructor.
Change-Id: I068bbe1c370a55053193b89931fb8f7da740de52
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
| -rw-r--r-- | tools/templates/interface.mako.server.cpp | 7 | ||||
| -rw-r--r-- | tools/templates/interface.mako.server.hpp | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tools/templates/interface.mako.server.cpp b/tools/templates/interface.mako.server.cpp index 16f7f43..590ee6b 100644 --- a/tools/templates/interface.mako.server.cpp +++ b/tools/templates/interface.mako.server.cpp @@ -13,6 +13,13 @@ namespace server namespace ${s} { % endfor + +${classname}::${classname}(bus::bus& bus, const char* path) + : _${"_".join(interface.name.split('.'))}_interface( + bus, path, _interface, _vtable, this) +{ +} + % for m in interface.methods: ${ m.cpp_prototype(loader, interface=interface, ptype='callback-cpp') } % endfor diff --git a/tools/templates/interface.mako.server.hpp b/tools/templates/interface.mako.server.hpp index ff18548..fa499b4 100644 --- a/tools/templates/interface.mako.server.hpp +++ b/tools/templates/interface.mako.server.hpp @@ -2,6 +2,8 @@ #include <tuple> #include <systemd/sd-bus.h> #include <sdbusplus/vtable.hpp> +#include <sdbusplus/interface.hpp> +#include <sdbusplus/bus.hpp> <% namespaces = interface.name.split('.') classname = namespaces.pop() @@ -18,6 +20,27 @@ namespace ${s} class ${classname} { public: + /* Define all of the basic class operations: + * Not allowed: + * - Default constructor to avoid nullptrs. + * - Copy operations due to internal unique_ptr. + * Allowed: + * - Move operations. + * - Destructor. + */ + ${classname}() = delete; + ${classname}(const ${classname}&) = delete; + ${classname}& operator=(const ${classname}&) = delete; + ${classname}(${classname}&&) = default; + ${classname}& operator=(${classname}&&) = default; + virtual ~${classname}() = default; + + /** @brief Constructor to put object onto bus at a dbus path. + * @param[in] bus - Bus to attach to. + * @param[in] path - Path to attach at. + */ + ${classname}(bus::bus& bus, const char* path); + % for m in interface.methods: ${ m.cpp_prototype(loader, interface=interface, ptype='header') } % endfor @@ -27,7 +50,10 @@ ${ m.cpp_prototype(loader, interface=interface, ptype='header') } ${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') } % endfor + static constexpr auto _interface = "${interface.name}"; static const sdbusplus::vtable::vtable_t _vtable[]; + interface::interface _${"_".join(interface.name.split('.'))}_interface; + }; % for s in namespaces: |

