sdbus-c++ 2.1.0
High-level C++ D-Bus library based on systemd D-Bus implementation
Loading...
Searching...
No Matches
ProxyInterfaces.h
Go to the documentation of this file.
1
27#ifndef SDBUS_CXX_PROXYINTERFACES_H_
28#define SDBUS_CXX_PROXYINTERFACES_H_
29
30#include <sdbus-c++/IProxy.h>
31#include <cassert>
32#include <string>
33#include <memory>
34
35// Forward declarations
36namespace sdbus {
37 class IConnection;
38}
39
40namespace sdbus {
41
42 /********************************************/
52 {
53 protected:
54 ProxyObjectHolder(std::unique_ptr<IProxy>&& proxy)
55 : proxy_(std::move(proxy))
56 {
57 assert(proxy_ != nullptr);
58 }
59
60 const IProxy& getProxy() const
61 {
62 assert(proxy_ != nullptr);
63 return *proxy_;
64 }
65
66 IProxy& getProxy()
67 {
68 assert(proxy_ != nullptr);
69 return *proxy_;
70 }
71
72 private:
73 std::unique_ptr<IProxy> proxy_;
74 };
75
76 /********************************************/
92 template <typename... _Interfaces>
94 : protected ProxyObjectHolder
95 , public _Interfaces...
96 {
97 public:
107 ProxyInterfaces(ServiceName destination, ObjectPath objectPath)
108 : ProxyObjectHolder(createProxy(std::move(destination), std::move(objectPath)))
109 , _Interfaces(getProxy())...
110 {
111 }
112
123 : ProxyObjectHolder(createProxy(std::move(destination), std::move(objectPath), dont_run_event_loop_thread))
124 , _Interfaces(getProxy())...
125 {
126 }
127
138 ProxyInterfaces(IConnection& connection, ServiceName destination, ObjectPath objectPath)
139 : ProxyObjectHolder(createProxy(connection, std::move(destination), std::move(objectPath)))
140 , _Interfaces(getProxy())...
141 {
142 }
143
154 ProxyInterfaces(std::unique_ptr<sdbus::IConnection>&& connection, ServiceName destination, ObjectPath objectPath)
155 : ProxyObjectHolder(createProxy(std::move(connection), std::move(destination), std::move(objectPath)))
156 , _Interfaces(getProxy())...
157 {
158 }
159
170 ProxyInterfaces(std::unique_ptr<sdbus::IConnection>&& connection, ServiceName destination, ObjectPath objectPath, dont_run_event_loop_thread_t)
171 : ProxyObjectHolder(createProxy(std::move(connection), std::move(destination), std::move(objectPath), dont_run_event_loop_thread))
172 , _Interfaces(getProxy())...
173 {
174 }
175
184 {
185 (_Interfaces::registerProxy(), ...);
186 }
187
196 {
198 }
199
203 using ProxyObjectHolder::getProxy;
204
205 protected:
206 using base_type = ProxyInterfaces;
207
208 ProxyInterfaces(const ProxyInterfaces&) = delete;
209 ProxyInterfaces& operator=(const ProxyInterfaces&) = delete;
211 ProxyInterfaces& operator=(ProxyInterfaces&&) = delete;
212 ~ProxyInterfaces() = default;
213 };
214
215}
216
217#endif /* SDBUS_CXX_INTERFACES_H_ */
std::unique_ptr< sdbus::IProxy > createProxy(sdbus::IConnection &connection, ServiceName destination, ObjectPath objectPath)
Creates a proxy object for a specific remote D-Bus object.
Definition Types.h:215
Definition IConnection.h:61
Definition IProxy.h:69
virtual void unregister()=0
Unregisters proxy's signal handlers and stops receiving replies to pending async calls.
Definition Types.h:195
Definition ProxyInterfaces.h:96
void unregisterProxy()
Unregisters the proxy so it no more receives signals and async call replies.
Definition ProxyInterfaces.h:195
ProxyInterfaces(std::unique_ptr< sdbus::IConnection > &&connection, ServiceName destination, ObjectPath objectPath, dont_run_event_loop_thread_t)
Creates native-like proxy object instance.
Definition ProxyInterfaces.h:170
void registerProxy()
Registers handlers for D-Bus signals of the remote object.
Definition ProxyInterfaces.h:183
ProxyInterfaces(ServiceName destination, ObjectPath objectPath)
Creates native-like proxy object instance.
Definition ProxyInterfaces.h:107
ProxyInterfaces(ServiceName destination, ObjectPath objectPath, dont_run_event_loop_thread_t)
Creates native-like proxy object instance.
Definition ProxyInterfaces.h:122
ProxyInterfaces(IConnection &connection, ServiceName destination, ObjectPath objectPath)
Creates native-like proxy object instance.
Definition ProxyInterfaces.h:138
ProxyInterfaces(std::unique_ptr< sdbus::IConnection > &&connection, ServiceName destination, ObjectPath objectPath)
Creates native-like proxy object instance.
Definition ProxyInterfaces.h:154
const IProxy & getProxy() const
Returns reference to the underlying IProxy instance.
Definition ProxyInterfaces.h:60
Definition ProxyInterfaces.h:52
Definition TypeTraits.h:101