sdbus++: generate header for server bindings
Add a 'server-header' command to sdbus++ that generates a class
definition for the server bindings. This class defines static
functions for registering as sd-bus callbacks and virtual C++
functions to implement the method behavior.
It is expected that a server implementation will create a class,
which inherits from this generated class, and implement all of
the method behaviors. Instances of the class will then register
on construction with sd-bus.
Signals and properties are not yet supported.
Change-Id: If0ec37b2acb6f8d528358004ec91dbe979644df7
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/tools/templates/interface.mako.server.hpp b/tools/templates/interface.mako.server.hpp
new file mode 100644
index 0000000..ff18548
--- /dev/null
+++ b/tools/templates/interface.mako.server.hpp
@@ -0,0 +1,37 @@
+#pragma once
+#include <tuple>
+#include <systemd/sd-bus.h>
+#include <sdbusplus/vtable.hpp>
+ <%
+ namespaces = interface.name.split('.')
+ classname = namespaces.pop()
+ %>
+namespace sdbusplus
+{
+namespace server
+{
+ % for s in namespaces:
+namespace ${s}
+{
+ % endfor
+
+class ${classname}
+{
+ public:
+ % for m in interface.methods:
+${ m.cpp_prototype(loader, interface=interface, ptype='header') }
+ % endfor
+
+ private:
+ % for m in interface.methods:
+${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') }
+ % endfor
+
+ static const sdbusplus::vtable::vtable_t _vtable[];
+};
+
+ % for s in namespaces:
+} // namespace ${s}
+ % endfor
+} // namespace server
+} // namespace sdbusplus