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