blob: 1d2364644b2082297fd96c02837440de1ea57dea [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
46 private:
47 % for m in interface.methods:
48${ m.cpp_prototype(loader, interface=interface, ptype='callback-header') }
49 % endfor
50
Patrick Williamsadc16822016-10-17 14:43:54 -050051 static constexpr auto _interface = "${interface.name}";
Patrick Williams0966ce82016-10-17 21:54:09 -050052 static const vtable::vtable_t _vtable[];
Patrick Williamsadc16822016-10-17 14:43:54 -050053 interface::interface _${"_".join(interface.name.split('.'))}_interface;
54
Patrick Williams04e007f2016-10-15 07:15:12 -050055};
56
57 % for s in namespaces:
58} // namespace ${s}
59 % endfor
60} // namespace server
61} // namespace sdbusplus