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>
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 ${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 @@
 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='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: