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