Patrick Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <tuple> |
| 3 | #include <systemd/sd-bus.h> |
| 4 | #include <sdbusplus/vtable.hpp> |
Patrick Williams | adc1682 | 2016-10-17 14:43:54 -0500 | [diff] [blame] | 5 | #include <sdbusplus/interface.hpp> |
| 6 | #include <sdbusplus/bus.hpp> |
Patrick Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame] | 7 | <% |
| 8 | namespaces = interface.name.split('.') |
| 9 | classname = namespaces.pop() |
| 10 | %> |
| 11 | namespace sdbusplus |
| 12 | { |
| 13 | namespace server |
| 14 | { |
| 15 | % for s in namespaces: |
| 16 | namespace ${s} |
| 17 | { |
| 18 | % endfor |
| 19 | |
| 20 | class ${classname} |
| 21 | { |
| 22 | public: |
Patrick Williams | adc1682 | 2016-10-17 14:43:54 -0500 | [diff] [blame] | 23 | /* 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 Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame] | 44 | % 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 Williams | adc1682 | 2016-10-17 14:43:54 -0500 | [diff] [blame] | 53 | static constexpr auto _interface = "${interface.name}"; |
Patrick Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame] | 54 | static const sdbusplus::vtable::vtable_t _vtable[]; |
Patrick Williams | adc1682 | 2016-10-17 14:43:54 -0500 | [diff] [blame] | 55 | interface::interface _${"_".join(interface.name.split('.'))}_interface; |
| 56 | |
Patrick Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | % for s in namespaces: |
| 60 | } // namespace ${s} |
| 61 | % endfor |
| 62 | } // namespace server |
| 63 | } // namespace sdbusplus |