Replace interface member with bus

Going forward a bus_t instance will be needed and as the interface
instance is accessible through bus_t, remove the interface member.

Tested: Executed the unit tests

    sdbusplus/build$ ninja test
    [0/1] Running all tests.
    1/20 test_async_task                     OK              0.03s
    2/20 test_bus_list_names                 OK              0.03s
    3/20 test_bus_match                      OK              0.02s
    4/20 test_exception_sdbus_error          OK              0.02s
    5/20 test_message_append                 OK              0.02s
    6/20 test_message_native_types           OK              0.01s
    7/20 test_message_read                   OK              0.03s
    8/20 test_message_types                  OK              0.02s
    9/20 test_unpack_properties              OK              0.02s
    10/20 test_utility_tuple_to_array         OK              0.02s
    11/20 test_utility_type_traits            OK              0.02s
    12/20 test-bus_aio                        OK              0.02s
    13/20 test-vtable                         OK              0.01s
    14/20 test-server                         OK              0.01s
    15/20 test-server-message-variant         OK              0.01s
    16/20 test_message_call                   OK              0.09s
    17/20 test_event_event                    OK              0.31s
    18/20 test_async_timer                    OK              0.51s
    19/20 test_async_context                  OK              0.52s
    20/20 test_timer                          OK             18.02s

    Ok:                 20
    Expected Fail:      0
    Fail:               0
    Unexpected Pass:    0
    Skipped:            0
    Timeout:            0

    [...]

Change-Id: If10fdf03885feb233e77259d477d17417218aa2d
Signed-off-by: Hannu Lounento <hannu.lounento@vaisala.com>
diff --git a/tools/sdbusplus/templates/interface.server.hpp.mako b/tools/sdbusplus/templates/interface.server.hpp.mako
index 6e5691d..079b441 100644
--- a/tools/sdbusplus/templates/interface.server.hpp.mako
+++ b/tools/sdbusplus/templates/interface.server.hpp.mako
@@ -47,7 +47,7 @@
         ${interface.classname}(bus_t& bus, const char* path) :
             _${interface.joinedName("_", "interface")}(
                 bus, path, interface, _vtable, this),
-            _intf(bus.getInterface()) {}
+            _sdbusplus_bus(bus) {}
 
     % if interface.properties:
         using PropertiesVariant = sdbusplus::utility::dedup_variant_t<
@@ -121,6 +121,12 @@
             _${interface.joinedName("_", "interface")}.emit_removed();
         }
 
+        /** @return the bus instance */
+        bus_t& get_bus()
+        {
+            return  _sdbusplus_bus;
+        }
+
     private:
     % for m in interface.methods:
 ${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') }
@@ -142,7 +148,7 @@
         static const vtable_t _vtable[];
         sdbusplus::server::interface_t
                 _${interface.joinedName("_", "interface")};
-        sdbusplus::SdBusInterface* _intf;
+        bus_t&  _sdbusplus_bus;
     % for p in interface.properties:
         % if p.defaultValue is not None:
         ${p.cppTypeParam(interface.name)} _${p.camelCase} = \
diff --git a/tools/sdbusplus/templates/method.prototype.hpp.mako b/tools/sdbusplus/templates/method.prototype.hpp.mako
index 569bf2c..d39491a 100644
--- a/tools/sdbusplus/templates/method.prototype.hpp.mako
+++ b/tools/sdbusplus/templates/method.prototype.hpp.mako
@@ -77,7 +77,7 @@
 <true>\
     % endif
 (
-                msg, o->_intf, error,
+                msg, o->get_bus().getInterface(), error,
                 std::function(
                     [=](${method.parameters_as_arg_list(interface)})
                     {
@@ -89,7 +89,7 @@
     % for e in method.errors:
     catch(const sdbusplus::${error_namespace(e)}::${error_name(e)}& e)
     {
-        return o->_intf->sd_bus_error_set(error, e.name(), e.description());
+        return o->get_bus().getInterface()->sd_bus_error_set(error, e.name(), e.description());
     }
     % endfor
 }
diff --git a/tools/sdbusplus/templates/property.prototype.hpp.mako b/tools/sdbusplus/templates/property.prototype.hpp.mako
index 86cd8dd..aa35671 100644
--- a/tools/sdbusplus/templates/property.prototype.hpp.mako
+++ b/tools/sdbusplus/templates/property.prototype.hpp.mako
@@ -33,7 +33,7 @@
     % endif
     {
         return sdbusplus::sdbuspp::property_callback(
-                reply, o->_intf, error,
+                reply, o->get_bus().getInterface(), error,
                 std::function(
                     [=]()
                     {
@@ -44,7 +44,7 @@
     % for e in property.errors:
     catch(const sdbusplus::${error_namespace(e)}::${error_name(e)}& e)
     {
-        return o->_intf->sd_bus_error_set(error, e.name(), e.description());
+        return o->get_bus().getInterface()->sd_bus_error_set(error, e.name(), e.description());
     }
     % endfor
 }
@@ -84,7 +84,7 @@
     % endif
     {
         return sdbusplus::sdbuspp::property_callback(
-                value, o->_intf, error,
+                value, o->get_bus().getInterface(), error,
                 std::function(
                     [=](${property.cppTypeParam(interface.name)}&& arg)
                     {
@@ -95,7 +95,7 @@
     % for e in property.errors:
     catch(const sdbusplus::${error_namespace(e)}::${error_name(e)}& e)
     {
-        return o->_intf->sd_bus_error_set(error, e.name(), e.description());
+        return o->get_bus().getInterface()->sd_bus_error_set(error, e.name(), e.description());
     }
     % endfor
 }