blob: fa499b4f1aaa599d11e973596de50282d150cc99 [file] [log] [blame]
Patrick Williams04e007f2016-10-15 07:15:12 -05001#pragma once
2#include <tuple>
3#include <systemd/sd-bus.h>
4#include <sdbusplus/vtable.hpp>
Patrick Williamsadc16822016-10-17 14:43:54 -05005#include <sdbusplus/interface.hpp>
6#include <sdbusplus/bus.hpp>
Patrick Williams04e007f2016-10-15 07:15:12 -05007 <%
8 namespaces = interface.name.split('.')
9 classname = namespaces.pop()
10 %>
11namespace sdbusplus
12{
13namespace server
14{
15 % for s in namespaces:
16namespace ${s}
17{
18 % endfor
19
20class ${classname}
21{
22 public:
Patrick Williamsadc16822016-10-17 14:43:54 -050023 /* Define all of the basic class operations:
24 * Not allowed:
25 * - Default constructor to avoid nullptrs.
26 * - Copy operations due to internal unique_ptr.
27 * Allowed:
28 * - Move operations.
29 * - Destructor.
30 */
31 ${classname}() = delete;
32 ${classname}(const ${classname}&) = delete;
33 ${classname}& operator=(const ${classname}&) = delete;
34 ${classname}(${classname}&&) = default;
35 ${classname}& operator=(${classname}&&) = default;
36 virtual ~${classname}() = default;
37
38 /** @brief Constructor to put object onto bus at a dbus path.
39 * @param[in] bus - Bus to attach to.
40 * @param[in] path - Path to attach at.
41 */
42 ${classname}(bus::bus& bus, const char* path);
43
Patrick Williams04e007f2016-10-15 07:15:12 -050044 % for m in interface.methods:
45${ m.cpp_prototype(loader, interface=interface, ptype='header') }
46 % endfor
47
48 private:
49 % for m in interface.methods:
50${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') }
51 % endfor
52
Patrick Williamsadc16822016-10-17 14:43:54 -050053 static constexpr auto _interface = "${interface.name}";
Patrick Williams04e007f2016-10-15 07:15:12 -050054 static const sdbusplus::vtable::vtable_t _vtable[];
Patrick Williamsadc16822016-10-17 14:43:54 -050055 interface::interface _${"_".join(interface.name.split('.'))}_interface;
56
Patrick Williams04e007f2016-10-15 07:15:12 -050057};
58
59 % for s in namespaces:
60} // namespace ${s}
61 % endfor
62} // namespace server
63} // namespace sdbusplus