1###
2### Emit 'header'
3###
4    % if ptype == 'header':
5        /** @brief Implementation for ${ method.name }
6         *  ${ method.description.strip() }
7    % if len(method.parameters) != 0:
8         *
9        % for p in method.parameters:
10         *  @param[in] ${p.camelCase} - ${p.description.strip()}
11        % endfor
12    % endif
13    % if len(method.returns) != 0:
14         *
15        % for r in method.returns:
16         *  @return ${r.camelCase}[${r.cppTypeParam(interface.name)}] \
17- ${r.description.strip()}
18        % endfor
19    % endif
20         */
21        virtual ${method.cpp_return_type(interface)} ${ method.camelCase }(
22            ${ method.get_parameters_str(interface) }) = 0;
23###
24### Emit 'callback-header'
25###
26    % elif ptype == 'callback-header':
27        /** @brief sd-bus callback for ${ method.name }
28         */
29        static int _callback_${ method.CamelCase }(
30            sd_bus_message*, void*, sd_bus_error*);
31###
32### Emit 'callback-cpp'
33###
34    % elif ptype == 'callback-cpp':
35int ${interface.classname}::_callback_${ method.CamelCase }(
36        sd_bus_message* msg, void* context, sd_bus_error* error)
37{
38    auto o = static_cast<${interface.classname}*>(context);
39
40    try
41    {
42        return sdbusplus::sdbuspp::method_callback\
43    % if len(method.returns) > 1:
44<true>\
45    % endif
46(
47                msg, o->get_bus().getInterface(), error,
48                std::function(
49                    [=](${method.parameters_as_arg_list(interface)})
50                    {
51                        return o->${ method.camelCase }(
52                                ${method.parameters_as_list()});
53                    }
54                ));
55    }
56    % for e in method.errors:
57    catch(const ${interface.errorNamespacedClass(e)}& e)
58    {
59        return o->get_bus().getInterface()->sd_bus_error_set(error, e.name(), e.description());
60    }
61    % endfor
62    catch (const std::exception&)
63    {
64        o->get_bus().set_current_exception(std::current_exception());
65        return 1;
66    }
67}
68
69namespace details
70{
71namespace ${interface.classname}
72{
73static const auto _param_${ method.CamelCase } =
74    % if len(method.parameters) == 0:
75        utility::tuple_to_array(std::make_tuple('\0'));
76    % else:
77        utility::tuple_to_array(message::types::type_id<
78                ${ method.parameter_types_as_list(interface) }>());
79    % endif
80static const auto _return_${ method.CamelCase } =
81    % if len(method.returns) == 0:
82        utility::tuple_to_array(std::make_tuple('\0'));
83    % else:
84        utility::tuple_to_array(message::types::type_id<
85                ${ method.returns_as_list(interface, full=True) }>());
86    % endif
87}
88}
89    % endif
90