15 #include <shared_mutex>
18 #include <sigc++/sigc++.h>
20 #ifndef DBUSCXX_OBJECTPROXY_H
21 #define DBUSCXX_OBJECTPROXY_H
28 class MethodProxyBase;
31 template <
typename signature>
class MethodProxy;
32 class PeerInterfaceProxy;
33 class IntrospectableInterfaceProxy;
34 class PropertiesInterfaceProxy;
58 static std::shared_ptr<ObjectProxy>
create(
const std::string&
path );
65 static std::shared_ptr<ObjectProxy>
create(
const std::string&
destination,
const std::string&
path );
67 static std::shared_ptr<ObjectProxy>
create( std::shared_ptr<Connection> conn,
const std::string&
path );
69 static std::shared_ptr<ObjectProxy>
create( std::shared_ptr<Connection> conn,
const std::string&
destination,
const std::string&
path );
85 typedef std::map<std::string, std::shared_ptr<InterfaceProxy>>
Interfaces;
90 std::shared_ptr<InterfaceProxy>
interface_by_name(
const std::string& name )
const;
93 bool add_interface( std::shared_ptr<InterfaceProxy> interface_ptr );
100 std::shared_ptr<InterfaceProxy>
create_interface(
const std::string& name );
110 bool has_interface( std::shared_ptr<InterfaceProxy> interface_ptr )
const;
113 bool add_method(
const std::string& interface_name, std::shared_ptr<MethodProxyBase> method );
115 std::shared_ptr<CallMessage>
create_call_message(
const std::string& interface_name,
const std::string& method_name )
const;
126 std::shared_ptr<const ReturnMessage>
call( std::shared_ptr<const CallMessage>,
int timeout_milliseconds = -1 )
const;
134 template <
class T_type>
135 std::shared_ptr<MethodProxy<T_type>>
136 create_method(
const std::string& interface_name,
const std::string& method_name ) {
137 std::shared_ptr<InterfaceProxy> interface_ptr = this->
interface_by_name( interface_name );
139 if( !interface_ptr ) { interface_ptr = this->
create_interface( interface_name ); }
141 return interface_ptr->create_method<T_type>( method_name );
150 template <
class T_type>
151 std::shared_ptr<SignalProxy<T_type> >
152 create_signal(
const std::string& interface_name,
const std::string& sig_name ) {
153 std::shared_ptr<InterfaceProxy> interface_ptr = this->
interface_by_name( interface_name );
155 if( !interface_ptr ) { interface_ptr = this->
create_interface( interface_name ); }
157 return interface_ptr->create_signal<T_type>( sig_name );
160 template <
class T_type>
161 std::shared_ptr<PropertyProxy<T_type>>
163 const std::string& property_name,
166 std::shared_ptr<InterfaceProxy> interface_ptr = this->
interface_by_name( interface_name );
168 if( !interface_ptr ) { interface_ptr = this->
create_interface( interface_name ); }
170 return interface_ptr->create_property<T_type>( property_name, update );
Object proxies are local proxies that provide local methods and signals for remote objects with dbus ...
Definition: objectproxy.h:44
void remove_interface(const std::string &name)
Removes the first interface with the given name.
Definition: objectproxy.cpp:149
std::shared_ptr< SignalProxy< T_type > > create_signal(const std::string &interface_name, const std::string &sig_name)
Creates a signal proxy with a signature based on the template parameters and adds it to the named int...
Definition: objectproxy.h:152
std::shared_ptr< CallMessage > create_call_message(const std::string &interface_name, const std::string &method_name) const
Definition: objectproxy.cpp:234
std::shared_ptr< PropertiesInterfaceProxy > getPropertiesInterface()
Definition: objectproxy.cpp:282
std::weak_ptr< Connection > connection() const
Definition: objectproxy.cpp:73
std::shared_ptr< const ReturnMessage > call(std::shared_ptr< const CallMessage >, int timeout_milliseconds=-1) const
Forwards this CallMessage to the Connection that this ObjectProxy is on, and returns a message with t...
Definition: objectproxy.cpp:258
std::shared_ptr< InterfaceProxy > interface_by_name(const std::string &name) const
Returns the first interface with the given name.
Definition: objectproxy.cpp:105
sigc::signal< void(std::shared_ptr< InterfaceProxy >)> signal_interface_removed()
Return a signal that you may connect to when an interface is removed.
Definition: objectproxy.cpp:270
std::shared_ptr< InterfaceProxy > create_interface(const std::string &name)
Creates and adds the named interface to this object.
Definition: objectproxy.cpp:139
std::shared_ptr< MethodProxy< T_type > > create_method(const std::string &interface_name, const std::string &method_name)
Creates a proxy method with a signature based on the template parameters and adds it to the named int...
Definition: objectproxy.h:136
void set_connection(std::shared_ptr< Connection > conn)
Definition: objectproxy.cpp:77
DBUS_CXX_PROPAGATE_CONST(std::unique_ptr< priv_data >) m_priv
sigc::signal< void(std::shared_ptr< InterfaceProxy >)> signal_interface_added()
Return a signal that you may connect to when an interface is added.
Definition: objectproxy.cpp:266
std::shared_ptr< PropertyProxy< T_type > > create_property(const std::string &interface_name, const std::string &property_name, PropertyAccess access_type=PropertyAccess::ReadWrite, PropertyUpdateType update=PropertyUpdateType::Updates)
Definition: objectproxy.h:162
std::shared_ptr< IntrospectableInterfaceProxy > getIntrospectableInterface()
Definition: objectproxy.cpp:278
std::map< std::string, std::shared_ptr< InterfaceProxy > > Interfaces
Definition: objectproxy.h:85
ObjectProxy(std::shared_ptr< Connection > conn, const std::string &destination, const std::string &path)
This class has a protected constructor.
Definition: objectproxy.cpp:47
void set_destination(const std::string &destination)
Definition: objectproxy.cpp:85
virtual ~ObjectProxy()
Definition: objectproxy.cpp:70
std::shared_ptr< PeerInterfaceProxy > getPeerInterface()
Definition: objectproxy.cpp:274
bool add_method(const std::string &interface_name, std::shared_ptr< MethodProxyBase > method)
Adds the method to the named interface.
Definition: objectproxy.cpp:224
static std::shared_ptr< ObjectProxy > create(const std::string &path)
Creates an ObjectProxy with a specific path.
Definition: objectproxy.cpp:54
bool has_interface(const std::string &name) const
Definition: objectproxy.cpp:192
void set_path(const std::string &path)
Definition: objectproxy.cpp:93
const std::string & destination() const
Definition: objectproxy.cpp:81
const Interfaces & interfaces() const
Definition: objectproxy.cpp:101
const Path & path() const
Definition: objectproxy.cpp:89
bool add_interface(std::shared_ptr< InterfaceProxy > interface_ptr)
Adds the interface to this object.
Definition: objectproxy.cpp:119
Represents a DBus Path.
Definition: path.h:21
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
PropertyAccess
Definition: enums.h:46
PropertyUpdateType
Definition: enums.h:23
@ Updates
When this property changes, the PropertyChanged signal will be emitted with the new value.