1#pragma once 2#include <sdbusplus/async/server.hpp> 3#include <sdbusplus/server/interface.hpp> 4#include <sdbusplus/server/transaction.hpp> 5 6#include <type_traits> 7 8% for h in interface.cpp_includes(): 9#include <${h}> 10% endfor 11#include <${interface.headerFile()}> 12 13namespace sdbusplus::aserver::${interface.cppNamespace()} 14{ 15 16namespace details 17{ 18// forward declaration 19template <typename Instance, typename Server> 20class ${interface.classname}; 21} // namespace details 22 23template <typename Instance, typename Server = void> 24struct ${interface.classname} : 25 public std::conditional_t< 26 std::is_void_v<Server>, 27 sdbusplus::async::server_t<Instance, details::${interface.classname}>, 28 details::${interface.classname}<Instance, Server>> 29{ 30 template <typename... Args> 31 ${interface.classname}(Args&&... args) : 32 std::conditional_t< 33 std::is_void_v<Server>, 34 sdbusplus::async::server_t<Instance, details::${interface.classname}>, 35 details::${interface.classname}<Instance, Server>>(std::forward<Args>(args)...) 36 {} 37}; 38 39namespace details 40{ 41 42namespace server_details = sdbusplus::async::server::details; 43 44template <typename Instance, typename Server> 45class ${interface.classname} : 46 public sdbusplus::common::${interface.cppNamespacedClass()}, 47 protected server_details::server_context_friend 48{ 49 public: 50 explicit ${interface.classname}(const char* path) : 51 _${interface.joinedName("_", "interface")}( 52 _context(), path, interface, _vtable, this) 53 {} 54 55% for s in interface.signals: 56${s.render(loader, "signal.aserver.emit.hpp.mako", signal=s, interface=interface)} 57% endfor 58 59 /** @brief Emit interface added */ 60 void emit_added() 61 { 62 _${interface.joinedName("_", "interface")}.emit_added(); 63 } 64 65 /** @brief Emit interface removed */ 66 void emit_removed() 67 { 68 _${interface.joinedName("_", "interface")}.emit_removed(); 69 } 70 71 /* Property access tags. */ 72% for p in interface.properties: 73${p.render(loader, "property.aserver.tag.hpp.mako", property=p, interface=interface)}\ 74% endfor 75 76 /* Method tags. */ 77% for m in interface.methods: 78${m.render(loader, "method.aserver.tag.hpp.mako", method=m, interface=interface)}\ 79% endfor 80 81% for p in interface.properties: 82${p.render(loader, "property.aserver.get.hpp.mako", property=p, interface=interface)} 83% endfor 84% for p in interface.properties: 85${p.render(loader, "property.aserver.set.hpp.mako", property=p, interface=interface)} 86% endfor 87 88 protected: 89% for p in interface.properties: 90${p.render(loader, "property.aserver.value.hpp.mako", property=p, interface=interface)}\ 91% endfor 92 93 private: 94 /** @return the async context */ 95 sdbusplus::async::context& _context() 96 { 97 return server_details::server_context_friend:: 98 context<Server, ${interface.classname}>(this); 99 } 100 101 sdbusplus::server::interface_t 102 _${interface.joinedName("_", "interface")}; 103 104% for p in interface.properties: 105${p.render(loader, "property.aserver.typeid.hpp.mako", property=p, interface=interface)}\ 106% endfor 107% for m in interface.methods: 108${m.render(loader, "method.aserver.typeid.hpp.mako", method=m, interface=interface)}\ 109% endfor 110% for s in interface.signals: 111${s.render(loader, "signal.aserver.typeid.hpp.mako", signal=s, interface=interface)}\ 112% endfor 113 114% for p in interface.properties: 115${p.render(loader, "property.aserver.callback.hpp.mako", property=p, interface=interface)} 116% endfor 117 118% for m in interface.methods: 119${m.render(loader, "method.aserver.callback.hpp.mako", method=m, interface=interface)}\ 120% endfor 121 122 static constexpr sdbusplus::vtable_t _vtable[] = { 123 vtable::start(), 124 125% for p in interface.properties: 126${p.render(loader, "property.aserver.vtable.hpp.mako", property=p, interface=interface)}\ 127% endfor 128% for m in interface.methods: 129${m.render(loader, "method.aserver.vtable.hpp.mako", method=m, interface=interface)}\ 130% endfor 131% for s in interface.signals: 132${s.render(loader, "signal.aserver.vtable.hpp.mako", signal=s, interface=interface)}\ 133% endfor 134 135 vtable::end(), 136 }; 137}; 138 139} // namespace details 140} // namespace sdbusplus::aserver::${interface.cppNamespace()} 141