1#pragma once 2#include <sdbusplus/async/client.hpp> 3#include <type_traits> 4 5% for h in interface.cpp_includes(): 6#include <${h}> 7% endfor 8#include <${interface.headerFile("common")}> 9 10#ifndef SDBUSPP_REMOVE_DEPRECATED_NAMESPACE 11namespace sdbusplus::${interface.old_cppNamespacedClass("client")} 12{ 13 14constexpr auto interface = 15 sdbusplus::common::${interface.cppNamespacedClass()}::interface; 16 17} // namespace sdbusplus::${interface.old_cppNamespacedClass("client")} 18#endif 19 20namespace sdbusplus::client::${interface.cppNamespace()} 21{ 22 23namespace details 24{ 25// forward declaration 26template <typename Proxy> 27class ${interface.classname}; 28} // namespace details 29 30/** Alias class so we can use the client in both a client_t aggregation 31 * and individually. 32 * 33 * sdbusplus::async::client_t<${interface.classname}>() or 34 * ${interface.classname}() both construct an equivalent instance. 35 */ 36template <typename Proxy = void> 37struct ${interface.classname} : 38 public std::conditional_t<std::is_void_v<Proxy>, 39 sdbusplus::async::client_t<details::${interface.classname}>, 40 details::${interface.classname}<Proxy>> 41{ 42 template <typename... Args> 43 ${interface.classname}(Args&&... args) : 44 std::conditional_t<std::is_void_v<Proxy>, 45 sdbusplus::async::client_t<details::${interface.classname}>, 46 details::${interface.classname}<Proxy>>( 47 std::forward<Args>(args)...) 48 {} 49}; 50 51namespace details 52{ 53 54template <typename Proxy> 55class ${interface.classname} : public sdbusplus::common::${interface.cppNamespacedClass()} 56{ 57 public: 58 template <bool, bool, bool, template <typename> typename...> 59 friend class sdbusplus::async::client::client; 60 template <typename> 61 friend class sdbusplus::client::${interface.cppNamespacedClass()}; 62 63 // Delete default constructor as these should only be constructed 64 // indirectly through sdbusplus::async::client_t. 65 ${interface.classname}() = delete; 66 67 % for m in interface.methods: 68${m.render(loader, "method.client.hpp.mako", method=m, interface=interface)} 69 % endfor 70 % for p in interface.properties: 71${p.render(loader, "property.client.hpp.mako", property=p, interface=interface)} 72 % endfor 73 private: 74 // Conversion constructor from proxy used by client_t. 75 constexpr ${interface.classname}(sdbusplus::async::context& ctx, Proxy p) : 76 ctx(ctx), proxy(p.interface(interface)) 77 {} 78 79 sdbusplus::async::context& ctx{}; 80 decltype(std::declval<Proxy>().interface(interface)) proxy = {}; 81}; 82 83} // namespace details 84 85} // namespace sdbusplus::client::${interface.cppNamespace()} 86