|
virtual MethodCall | createMethodCall (const std::string &interfaceName, const std::string &methodName)=0 |
| Creates a method call message. More...
|
|
virtual MethodReply | callMethod (const MethodCall &message, uint64_t timeout=0)=0 |
| Calls method on the D-Bus object. More...
|
|
template<typename _Rep , typename _Period > |
MethodReply | callMethod (const MethodCall &message, const std::chrono::duration< _Rep, _Period > &timeout) |
| Calls method on the D-Bus object. More...
|
|
virtual PendingAsyncCall | callMethod (const MethodCall &message, async_reply_handler asyncReplyCallback, uint64_t timeout=0)=0 |
| Calls method on the D-Bus object asynchronously. More...
|
|
template<typename _Rep , typename _Period > |
PendingAsyncCall | callMethod (const MethodCall &message, async_reply_handler asyncReplyCallback, const std::chrono::duration< _Rep, _Period > &timeout) |
| Calls method on the D-Bus object asynchronously. More...
|
|
virtual void | registerSignalHandler (const std::string &interfaceName, const std::string &signalName, signal_handler signalHandler)=0 |
| Registers a handler for the desired signal emitted by the D-Bus object. More...
|
|
virtual void | unregisterSignalHandler (const std::string &interfaceName, const std::string &signalName)=0 |
| Unregisters the handler of the desired signal. More...
|
|
virtual void | finishRegistration ()=0 |
| Finishes the registration of signal handlers. More...
|
|
virtual void | unregister ()=0 |
| Unregisters proxy's signal handlers and stops receving replies to pending async calls. More...
|
|
MethodInvoker | callMethod (const std::string &methodName) |
| Calls method on the D-Bus object. More...
|
|
AsyncMethodInvoker | callMethodAsync (const std::string &methodName) |
| Calls method on the D-Bus object asynchronously. More...
|
|
SignalSubscriber | uponSignal (const std::string &signalName) |
| Registers signal handler for a given signal of the D-Bus object. More...
|
|
SignalUnsubscriber | muteSignal (const std::string &signalName) |
| Unregisters signal handler of a given signal of the D-Bus object. More...
|
|
PropertyGetter | getProperty (const std::string &propertyName) |
| Gets value of a property of the D-Bus object. More...
|
|
AsyncPropertyGetter | getPropertyAsync (const std::string &propertyName) |
| Gets value of a property of the D-Bus object asynchronously. More...
|
|
PropertySetter | setProperty (const std::string &propertyName) |
| Sets value of a property of the D-Bus object. More...
|
|
AsyncPropertySetter | setPropertyAsync (const std::string &propertyName) |
| Sets value of a property of the D-Bus object asynchronously. More...
|
|
AllPropertiesGetter | getAllProperties () |
| Gets values of all properties of the D-Bus object. More...
|
|
AsyncAllPropertiesGetter | getAllPropertiesAsync () |
| Gets values of all properties of the D-Bus object asynchronously. More...
|
|
virtual sdbus::IConnection & | getConnection () const =0 |
| Provides D-Bus connection used by the proxy. More...
|
|
virtual const std::string & | getObjectPath () const =0 |
| Returns object path of the underlying DBus object.
|
|
virtual const Message * | getCurrentlyProcessedMessage () const =0 |
| Provides currently processed D-Bus message. More...
|
|
virtual std::future< MethodReply > | callMethod (const MethodCall &message, with_future_t)=0 |
| Calls method on the D-Bus object asynchronously. More...
|
|
virtual std::future< MethodReply > | callMethod (const MethodCall &message, uint64_t timeout, with_future_t)=0 |
|
template<typename _Rep , typename _Period > |
std::future< MethodReply > | callMethod (const MethodCall &message, const std::chrono::duration< _Rep, _Period > &timeout, with_future_t) |
|
IProxy class represents a proxy object, which is a convenient local object created to represent a remote D-Bus object in another process. The proxy enables calling methods on remote objects, receiving signals from remote objects, and getting/setting properties of remote objects.
All IProxy member methods throw sdbus::Error
in case of D-Bus or sdbus-c++ error. The IProxy class has been designed as thread-aware. However, the operation of creating and sending method calls (both synchronously and asynchronously) is thread-safe by design.
template<typename _Rep , typename _Period >
PendingAsyncCall sdbus::IProxy::callMethod |
( |
const MethodCall & |
message, |
|
|
async_reply_handler |
asyncReplyCallback, |
|
|
const std::chrono::duration< _Rep, _Period > & |
timeout |
|
) |
| |
|
inline |
Calls method on the D-Bus object asynchronously.
- Parameters
-
[in] | message | Message representing an async method call |
[in] | asyncReplyCallback | Handler for the async reply |
[in] | timeout | Timeout for dbus call in microseconds |
- Returns
- Cookie for the the pending asynchronous call
The call is non-blocking. It doesn't wait for the reply. Once the reply arrives, the provided async reply handler will get invoked from the context of the connection I/O event loop thread.
Note: To avoid messing with messages, use higher-level API defined below.
- Exceptions
-
template<typename _Rep , typename _Period >
MethodReply sdbus::IProxy::callMethod |
( |
const MethodCall & |
message, |
|
|
const std::chrono::duration< _Rep, _Period > & |
timeout |
|
) |
| |
|
inline |
Calls method on the D-Bus object.
- Parameters
-
[in] | message | Message representing a method call |
[in] | timeout | Timeout for dbus call in microseconds |
- Returns
- A method reply message
Normally, the call is blocking, i.e. it waits for the remote method to finish with either a return value or an error.
If the method call argument is set to not expect reply, the call will not wait for the remote method to finish, i.e. the call will be non-blocking, and the function will return an empty, invalid MethodReply object (representing void).
Note: To avoid messing with messages, use higher-level API defined below.
- Exceptions
-
Calls method on the D-Bus object.
- Parameters
-
[in] | message | Message representing a method call |
[in] | timeout | Timeout for dbus call in microseconds |
- Returns
- A method reply message
Normally, the call is blocking, i.e. it waits for the remote method to finish with either a return value or an error.
If the method call argument is set to not expect reply, the call will not wait for the remote method to finish, i.e. the call will be non-blocking, and the function will return an empty, invalid MethodReply object (representing void).
Note: To avoid messing with messages, use higher-level API defined below.
- Exceptions
-
virtual const Message* sdbus::IProxy::getCurrentlyProcessedMessage |
( |
| ) |
const |
|
pure virtual |
Provides currently processed D-Bus message.
This method provides immutable access to the currently processed incoming D-Bus message. "Currently processed" means that the registered callback handler(s) for that message are being invoked. This method is meant to be called from within a callback handler (e.g. from a D-Bus signal handler, or async method reply handler, etc.). In such a case it is guaranteed to return a valid pointer to the D-Bus message for which the handler is called. If called from other contexts/threads, it may return a nonzero pointer or a nullptr, depending on whether a message was processed at the time of call or not, but the value is nondereferencable, since the pointed-to message may have gone in the meantime.
- Returns
- A pointer to the currently processed D-Bus message