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
26template <typename Proxy>
27class ${interface.classname} :
28    public sdbusplus::common::${interface.cppNamespacedClass()}
29{
30  public:
31    template <bool S, bool P, bool Preserved,
32              template <typename> typename... Types>
33    friend class sdbusplus::async::client::client;
34    // Delete default constructor as these should only be constructed
35    // indirectly through sdbusplus::async::client_t.
36    ${interface.classname}() = delete;
37
38    % for m in interface.methods:
39${m.render(loader, "method.client.hpp.mako", method=m, interface=interface)}
40    % endfor
41
42    // To be replaced by generators...
43    template <typename T>
44    auto get_property(auto& property) const
45    {
46        return proxy.template get_property<T>(ctx, property);
47    }
48
49    // To be replaced by generators...
50    template <typename T>
51    auto set_property(auto& property, T&& value) const
52    {
53        return proxy.template set_property<T>(ctx, property,
54                                              std::forward<T>(value));
55    }
56
57  private:
58    // Conversion constructor from proxy used by client_t.
59    constexpr ${interface.classname}(sdbusplus::async::context& ctx, Proxy p) :
60        ctx(ctx), proxy(p.interface(interface)) {}
61
62    sdbusplus::async::context& ctx{};
63    decltype(std::declval<Proxy>().interface(interface)) proxy = {};
64};
65
66} // namespace details
67
68/** Alias class so we can use the client in both a client_t aggregation
69 *  and individually.
70 *
71 *  sdbusplus::async::client_t<${interface.classname}>() or
72 *  ${interface.classname}() both construct an equivalent instance.
73 */
74template <typename Proxy = void>
75struct ${interface.classname} : public
76    std::conditional_t<
77        std::is_void_v<Proxy>,
78        sdbusplus::async::client_t<details::${interface.classname}>,
79        details::${interface.classname}<Proxy>>
80{
81    template <typename... Args>
82    ${interface.classname}(Args&&... args) :
83        std::conditional_t<std::is_void_v<Proxy>,
84                           sdbusplus::async::client_t<details::${interface.classname}>,
85                           details::${interface.classname}<Proxy>>(
86            std::forward<Args>(args)...)
87    {}
88};
89
90} // namespace sdbusplus::client::${interface.cppNamespacedClass()}
91