sdbus-c++ 1.5.0
High-level C++ D-Bus library based on systemd D-Bus implementation
|
#include <IProxy.h>
Public Member Functions | |
virtual MethodCall | createMethodCall (const std::string &interfaceName, const std::string &methodName)=0 |
Creates a method call message. | |
virtual MethodReply | callMethod (const MethodCall &message, uint64_t timeout=0)=0 |
Calls method on the D-Bus object. | |
template<typename _Rep , typename _Period > | |
MethodReply | callMethod (const MethodCall &message, const std::chrono::duration< _Rep, _Period > &timeout) |
Calls method on the D-Bus object. | |
virtual PendingAsyncCall | callMethod (const MethodCall &message, async_reply_handler asyncReplyCallback, uint64_t timeout=0)=0 |
Calls method on the D-Bus object asynchronously. | |
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. | |
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. | |
virtual void | unregisterSignalHandler (const std::string &interfaceName, const std::string &signalName)=0 |
Unregisters the handler of the desired signal. | |
virtual void | finishRegistration ()=0 |
Finishes the registration of signal handlers. | |
virtual void | unregister ()=0 |
Unregisters proxy's signal handlers and stops receving replies to pending async calls. | |
MethodInvoker | callMethod (const std::string &methodName) |
Calls method on the D-Bus object. | |
AsyncMethodInvoker | callMethodAsync (const std::string &methodName) |
Calls method on the D-Bus object asynchronously. | |
SignalSubscriber | uponSignal (const std::string &signalName) |
Registers signal handler for a given signal of the D-Bus object. | |
SignalUnsubscriber | muteSignal (const std::string &signalName) |
Unregisters signal handler of a given signal of the D-Bus object. | |
PropertyGetter | getProperty (const std::string &propertyName) |
Gets value of a property of the D-Bus object. | |
AsyncPropertyGetter | getPropertyAsync (const std::string &propertyName) |
Gets value of a property of the D-Bus object asynchronously. | |
PropertySetter | setProperty (const std::string &propertyName) |
Sets value of a property of the D-Bus object. | |
AsyncPropertySetter | setPropertyAsync (const std::string &propertyName) |
Sets value of a property of the D-Bus object asynchronously. | |
AllPropertiesGetter | getAllProperties () |
Gets values of all properties of the D-Bus object. | |
AsyncAllPropertiesGetter | getAllPropertiesAsync () |
Gets values of all properties of the D-Bus object asynchronously. | |
virtual sdbus::IConnection & | getConnection () const =0 |
Provides D-Bus connection used by the proxy. | |
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. | |
virtual std::future< MethodReply > | callMethod (const MethodCall &message, with_future_t)=0 |
Calls method on the D-Bus object asynchronously. | |
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.
|
inline |
Calls method on the D-Bus object asynchronously.
[in] | message | Message representing an async method call |
[in] | asyncReplyCallback | Handler for the async reply |
[in] | timeout | Timeout for dbus call in microseconds |
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.
sdbus::Error | in case of failure |
|
pure virtual |
Calls method on the D-Bus object asynchronously.
[in] | message | Message representing an async method call |
[in] | asyncReplyCallback | Handler for the async reply |
[in] | timeout | Timeout for dbus call in microseconds |
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.
sdbus::Error | in case of failure |
|
inline |
Calls method on the D-Bus object.
[in] | message | Message representing a method call |
[in] | timeout | Timeout for dbus call in microseconds |
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.
sdbus::Error | in case of failure |
|
inline |
|
pure virtual |
Calls method on the D-Bus object.
[in] | message | Message representing a method call |
[in] | timeout | Timeout for dbus call in microseconds |
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.
sdbus::Error | in case of failure |
|
pure virtual |
Calls method on the D-Bus object asynchronously.
[in] | message | Message representing an async method call |
[in] | asyncReplyCallback | Handler for the async reply |
[in] | timeout | Timeout for dbus call in microseconds |
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.
sdbus::Error | in case of failure |
|
inline |
Calls method on the D-Bus object.
[in] | methodName | Name of the method |
This is a high-level, convenience way of calling D-Bus methods that abstracts from the D-Bus message concept. Method arguments/return value are automatically (de)serialized in a message and D-Bus signatures automatically deduced from the provided native arguments and return values.
Example of use:
sdbus::Error | in case of failure |
|
inline |
Calls method on the D-Bus object asynchronously.
[in] | methodName | Name of the method |
This is a high-level, convenience way of calling D-Bus methods that abstracts from the D-Bus message concept. Method arguments/return value are automatically (de)serialized in a message and D-Bus signatures automatically deduced from the provided native arguments and return values.
Example of use:
sdbus::Error | in case of failure |
|
pure virtual |
Creates a method call message.
[in] | interfaceName | Name of an interface that provides a given method |
[in] | methodName | Name of the method |
Serialize method arguments into the returned message and invoke the method by passing the message with serialized arguments to the callMethod
function. Alternatively, use higher-level API callMethod(const std::string& methodName)
defined below.
sdbus::Error | in case of failure |
|
pure virtual |
Finishes the registration of signal handlers.
The method physically subscribes to the desired signals. Must be called only once, after all signals have been registered already.
sdbus::Error | in case of failure |
|
inline |
Gets values of all properties of the D-Bus object.
This is a high-level, convenience way of reading D-Bus properties' values that abstracts from the D-Bus message concept.
Example of use:
sdbus::Error | in case of failure |
|
inline |
Gets values of all properties of the D-Bus object asynchronously.
This is a high-level, convenience way of reading D-Bus properties' values that abstracts from the D-Bus message concept.
Example of use:
sdbus::Error | in case of failure |
|
pure virtual |
Provides D-Bus connection used by the proxy.
|
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.
|
inline |
Gets value of a property of the D-Bus object.
[in] | propertyName | Name of the property |
This is a high-level, convenience way of reading D-Bus property values that abstracts from the D-Bus message concept. sdbus::Variant is returned which shall then be converted to the real property type (implicit conversion is supported).
Example of use:
sdbus::Error | in case of failure |
|
inline |
Gets value of a property of the D-Bus object asynchronously.
[in] | propertyName | Name of the property |
This is a high-level, convenience way of reading D-Bus property values that abstracts from the D-Bus message concept.
Example of use:
sdbus::Error | in case of failure |
|
inline |
Unregisters signal handler of a given signal of the D-Bus object.
[in] | signalName | Name of the signal |
This is a high-level, convenience way of unregistering a D-Bus signal's handler.
Example of use:
sdbus::Error | in case of failure |
|
pure virtual |
Registers a handler for the desired signal emitted by the D-Bus object.
[in] | interfaceName | Name of an interface that the signal belongs to |
[in] | signalName | Name of the signal |
[in] | signalHandler | Callback that implements the body of the signal handler |
sdbus::Error | in case of failure |
|
inline |
Sets value of a property of the D-Bus object.
[in] | propertyName | Name of the property |
This is a high-level, convenience way of writing D-Bus property values that abstracts from the D-Bus message concept. Setting property value with NoReply flag is also supported.
Example of use:
sdbus::Error | in case of failure |
|
inline |
Sets value of a property of the D-Bus object asynchronously.
[in] | propertyName | Name of the property |
This is a high-level, convenience way of writing D-Bus property values that abstracts from the D-Bus message concept.
Example of use:
sdbus::Error | in case of failure |
|
pure virtual |
Unregisters proxy's signal handlers and stops receving replies to pending async calls.
Unregistration is done automatically also in proxy's destructor. This method makes sense if, in the process of proxy removal, we need to make sure that callbacks are unregistered explicitly before the final destruction of the proxy instance.
sdbus::Error | in case of failure |
|
pure virtual |
Unregisters the handler of the desired signal.
[in] | interfaceName | Name of an interface that the signal belongs to |
[in] | signalName | Name of the signal |
sdbus::Error | in case of failure |
|
inline |
Registers signal handler for a given signal of the D-Bus object.
[in] | signalName | Name of the signal |
This is a high-level, convenience way of registering to D-Bus signals that abstracts from the D-Bus message concept. Signal arguments are automatically serialized in a message and D-Bus signatures automatically deduced from the parameters of the provided native signal callback.
Example of use:
sdbus::Error | in case of failure |