17 #include <shared_mutex>
20 #include <sigc++/sigc++.h>
22 #ifndef DBUSCXXOBJECT_H
23 #define DBUSCXXOBJECT_H
29 template <
typename T_type>
class Method;
69 typedef std::map<std::string, std::shared_ptr<Interface> >
Interfaces;
81 typedef std::map<std::string, std::shared_ptr<Object>>
Children;
87 static std::shared_ptr<Object>
create(
const std::string&
path = std::string() );
143 template <
typename T_type>
144 std::shared_ptr<Method<T_type> >
153 std::shared_ptr< Method<T_type> > method;
155 method->set_method( slot );
169 template <
typename T_type>
170 std::shared_ptr<Method<T_type> >
171 create_method(
const std::string& interface_name,
const std::string& method_name, sigc::slot<T_type> slot ) {
172 std::shared_ptr<Interface> interface_ptr;
175 if( !interface_ptr ) { interface_ptr = this->
create_interface( interface_name ); }
179 std::shared_ptr< Method<T_type> > method;
180 method = interface_ptr->create_method<T_type>( method_name );
181 method->set_method( slot );
185 template <
typename T_type>
186 std::shared_ptr<Property<T_type>>
188 const std::string& property_name,
191 std::shared_ptr<Interface> interface_ptr;
194 if( !interface_ptr ) { interface_ptr = this->
create_interface( interface_name ); }
196 return interface_ptr->create_property<T_type>( property_name, access_type, update_type );
256 template <
class... T_type>
257 std::shared_ptr<
Signal<T_type...> >
264 sig = iface->create_signal<T_type...>( name );
277 template <
class... T_type>
278 std::shared_ptr<
Signal<T_type...> >
296 std::shared_ptr<Object>
child(
const std::string& name )
const;
307 bool add_child(
const std::string& name, std::shared_ptr<Object>
child,
bool force =
false );
321 bool has_child(
const std::string& name )
const;
324 std::string
introspect(
int space_depth = 0 )
const;
An Object represents a local object that is able to be called over the DBus.
Definition: object.h:50
static std::shared_ptr< Object > create(const std::string &path=std::string())
Creates a named Object that will register as a primary or fallback handler.
Definition: object.cpp:54
HandlerResult handle_message(std::shared_ptr< const Message > msg)
Handles the specified message on the specified connection.
Definition: object.cpp:346
std::shared_ptr< Interface > create_interface(const std::string &name)
Creates and adds the named interface to this object.
Definition: object.cpp:149
const Path & path() const
Returns the path this handler is associated with.
Definition: object.cpp:61
virtual ~Object()
Definition: object.cpp:58
std::shared_ptr< Interface > default_interface() const
Get the default interface associated with this object.
Definition: object.cpp:198
bool remove_child(const std::string &name)
Remove the named child from this object.
Definition: object.cpp:267
std::shared_ptr< Signal< T_type... > > create_signal(const std::string &name)
Creates a signal with a return value (possibly void ) and a variable number of parameters and adds it...
Definition: object.h:258
std::string introspect(int space_depth=0) const
Returns a DBus XML description of this interface.
Definition: object.cpp:280
const Children & children() const
Get the children associated with this object instance.
Definition: object.cpp:239
Object(const std::string &path)
This class has a protected constructor.
Definition: object.cpp:49
const Interfaces & interfaces() const
Get all the interfaces associated with this Object instance.
Definition: object.cpp:100
std::shared_ptr< Object > child(const std::string &name) const
Get a named child of this object.
Definition: object.cpp:243
std::shared_ptr< Method< T_type > > create_method(const std::string &interface_name, const std::string &method_name, sigc::slot< T_type > slot)
Creates a method with a signature based on the.
Definition: object.h:171
bool has_child(const std::string &name) const
Test whether an object has a child with a specified name.
Definition: object.cpp:276
std::map< std::string, std::shared_ptr< Object > > Children
Typedef to storage structure for an Object instance's children.
Definition: object.h:81
std::shared_ptr< Signal< T_type... > > create_signal(const std::string &iface, const std::string &name)
Creates a signal with a return value (possibly void ) and a variable number of parameters and adds it...
Definition: object.h:279
bool set_default_interface(const std::string &new_default_name)
Set the default interface to a specific name.
Definition: object.cpp:202
DBUS_CXX_PROPAGATE_CONST(std::unique_ptr< priv_data >) m_priv
bool add_interface(std::shared_ptr< Interface > interface_by_name)
Adds the interface to this object.
Definition: object.cpp:118
sigc::signal< void(std::shared_ptr< Connection >) > & signal_registered()
Emitted when this object is registered with a connection.
Definition: object.cpp:77
sigc::signal< void(std::shared_ptr< Interface >) > signal_interface_removed()
Signal emitted when an interface is removed from this object.
Definition: object.cpp:338
bool unregister()
Unregisters the handler.
Definition: object.cpp:69
std::map< std::string, std::shared_ptr< Interface > > Interfaces
Typedef to the storage structure for an Object instance's interfaces.
Definition: object.h:69
bool has_interface(const std::string &name)
Test whether an Object has a named interface.
Definition: object.cpp:189
std::shared_ptr< Interface > interface_by_name(const std::string &name) const
Returns the interface with the given name.
Definition: object.cpp:104
void set_connection(std::shared_ptr< Connection > conn)
Sets the connection that this object is on.
Definition: object.cpp:85
void remove_interface(const std::string &name)
Removes the interface found with the given name.
Definition: object.cpp:161
sigc::signal< void(std::shared_ptr< Interface >) > signal_interface_added()
Signal emitted when an interface is added to this object.
Definition: object.cpp:334
sigc::signal< void(std::shared_ptr< Connection >) > & signal_unregistered()
Emitted when this object is unregistered from a connection.
Definition: object.cpp:81
std::shared_ptr< Property< T_type > > create_property(const std::string &interface_name, const std::string &property_name, PropertyAccess access_type=PropertyAccess::ReadWrite, PropertyUpdateType update_type=PropertyUpdateType::Updates)
Definition: object.h:187
std::shared_ptr< Method< T_type > > create_method(const std::string &method_name, sigc::slot< T_type > slot)
Creates a method with a signature based on the.
Definition: object.h:145
std::weak_ptr< Connection > connection() const
Returns the connection this handler is registered with.
Definition: object.cpp:65
bool add_child(const std::string &name, std::shared_ptr< Object > child, bool force=false)
Add an object as a child with a specified name This method will fail if the object already has a chil...
Definition: object.cpp:251
sigc::signal< void(std::shared_ptr< Interface >, std::shared_ptr< Interface >)> signal_default_interface_changed()
Signal emitted when the default interface of this object is changed.
Definition: object.cpp:342
void remove_default_interface()
Removes the currently set (if any) default interface.
Definition: object.cpp:231
Represents a DBus Path.
Definition: path.h:21
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
PropertyAccess
Definition: enums.h:46
HandlerResult
Definition: enums.h:95
PropertyUpdateType
Definition: enums.h:23
@ Updates
When this property changes, the PropertyChanged signal will be emitted with the new value.