An Interface represents a local copy of a DBus interface. More...
#include <interface.h>
Public Types | |
typedef std::map< std::string, std::shared_ptr< MethodBase > > | Methods |
Typedef to the storage structure for methods. More... | |
typedef std::set< std::shared_ptr< SignalBase > > | Signals |
Typedef to the storage structure for signals. More... | |
Public Member Functions | |
virtual | ~Interface () |
HandlerResult | handle_call_message (std::shared_ptr< Connection > conn, std::shared_ptr< const CallMessage > message) |
Handles the specified call message. More... | |
HandlerResult | handle_properties_message (std::shared_ptr< Connection > conn, std::shared_ptr< const CallMessage > message) |
Handle the specified properties message. More... | |
const std::string & | name () const |
Get the name of this interface. More... | |
Path | path () const |
Returns the path of the object associated with this interface or a null string if no object is associated. More... | |
const Methods & | methods () const |
Returns the methods associated with this interface. More... | |
std::shared_ptr< MethodBase > | method (const std::string &name) const |
Returns the method with the given name, or an invalid shared_ptr if not found. More... | |
template<typename T_type > | |
std::shared_ptr< Method< T_type > > | create_method (const std::string &name) |
Creates a method with a return value (possibly void ) and $1 parameters. More... | |
template<typename T_type > | |
std::shared_ptr< Method< T_type > > | create_method (const std::string &name, sigc::slot< T_type > slot) |
Creates a method with a signature equivalent to the provided. More... | |
template<typename T_type > | |
std::shared_ptr< Property< T_type > > | create_property (const std::string &name, PropertyAccess access_type=PropertyAccess::ReadWrite, PropertyUpdateType update_type=PropertyUpdateType::Updates) |
bool | add_property (std::shared_ptr< PropertyBase > prop) |
bool | has_property (const std::string &name) const |
bool | add_method (std::shared_ptr< MethodBase > method) |
Adds the named method. More... | |
bool | remove_method (const std::string &name) |
Removes the first method with the given name. More... | |
bool | remove_method (std::shared_ptr< MethodBase > method) |
Removes the given method, if found. More... | |
bool | has_method (const std::string &name) const |
True if the interface has a method with the given name. More... | |
bool | add_signal (std::shared_ptr< SignalBase > signal) |
Adds the given signal. More... | |
bool | remove_signal (std::shared_ptr< SignalBase > signal) |
Removes the given signal. More... | |
bool | remove_signal (const std::string &name) |
Removes all signals with the given name. More... | |
bool | has_signal (std::shared_ptr< SignalBase > signal) const |
True if the given signal is part of this interface. More... | |
bool | has_signal (const std::string &name) const |
True if this interface has at least one signal with the given name. More... | |
template<class... T_type> | |
std::shared_ptr< Signal< T_type... > > | create_signal (const std::string &member) |
Creates a signal with any number of parameters. More... | |
const Signals & | signals () |
Returns the signals associated with this interface. More... | |
const std::set< std::shared_ptr< PropertyBase > > & | properties () |
std::shared_ptr< SignalBase > | signal (const std::string &signal_name) |
Returns the first signal found with a matching name. More... | |
sigc::signal< void(std::shared_ptr< MethodBase >)> | signal_method_added () |
Signal emitted when a method of the given name is added. More... | |
sigc::signal< void(std::shared_ptr< MethodBase >)> | signal_method_removed () |
Signal emitted when a method of the given name is removed. More... | |
std::string | introspect (int space_depth=0) const |
Returns a DBus XML description of this interface. More... | |
Static Public Member Functions | |
static std::shared_ptr< Interface > | create (const std::string &name=std::string()) |
Creates a named Interface. More... | |
Protected Member Functions | |
Interface (const std::string &name) | |
This class has a protected constructor. More... | |
Private Member Functions | |
void | set_path (const std::string &new_path) |
void | property_updated (DBus::PropertyBase *prop) |
void | set_connection (std::weak_ptr< Connection > conn) |
DBUS_CXX_PROPAGATE_CONST (std::unique_ptr< priv_data >) m_priv | |
Friends | |
class | Object |
class | PropertyBase |
An Interface represents a local copy of a DBus interface.
A DBus interface is an entry point that allows for object-orinted manipulation of local objects. Interfaces contain two ore more elements separated by the period ('.') character.
typedef std::map<std::string, std::shared_ptr<MethodBase> > DBus::Interface::Methods |
Typedef to the storage structure for methods.
Data Structure - map Key - method name Value -smart pointer to a method.
Can access type as Interface::Methods
typedef std::set<std::shared_ptr<SignalBase> > DBus::Interface::Signals |
Typedef to the storage structure for signals.
Data Structure - sets is used since signal names are not needed for the interface, but must be unique.
Can access type as Interface::Signals
|
protected |
|
virtual |
bool DBus::Interface::add_method | ( | std::shared_ptr< MethodBase > | method | ) |
bool DBus::Interface::add_property | ( | std::shared_ptr< PropertyBase > | prop | ) |
References has_property().
Referenced by create_property().
bool DBus::Interface::add_signal | ( | std::shared_ptr< SignalBase > | signal | ) |
Adds the given signal.
References LOGGER_NAME, name(), path(), and SIMPLELOGGER_DEBUG.
Referenced by create_signal().
|
static |
Creates a named Interface.
name | The name of this interface |
References Interface(), and name().
Referenced by DBus::Object::create_interface().
|
inline |
Creates a method with a return value (possibly void
) and $1 parameters.
name | The name that will be associated with this method |
References add_method(), DBus::Method< T_type >::create(), method(), and name().
|
inline |
Creates a method with a signature equivalent to the provided.
slot | parameter's signature |
slot | This slot will be called with the given signature when the method is invoked |
Template parameters of the sigc::slot will determine the signature of the method created.
References add_method(), DBus::Method< T_type >::create(), method(), and name().
|
inline |
References add_property(), DBus::Property< T_type >::create(), and name().
|
inline |
Creates a signal with any number of parameters.
name | The name that will be associated with this signal |
References add_signal(), name(), and path().
|
private |
HandlerResult DBus::Interface::handle_call_message | ( | std::shared_ptr< Connection > | conn, |
std::shared_ptr< const CallMessage > | message | ||
) |
Handles the specified call message.
Looks for methods matching the name specified in the message, then calls handle_call_message() for each matching message.
Once a method returns HANDLED
no further methods will be tried.
HANDLED
if one method in this interface handled the message, NOT_HANDLED
otherwise conn | The Connection to send the reply message on |
msg | The CallMessage to handle |
References DBus::Invalid_Method, LOGGER_NAME, method(), and SIMPLELOGGER_DEBUG.
HandlerResult DBus::Interface::handle_properties_message | ( | std::shared_ptr< Connection > | conn, |
std::shared_ptr< const CallMessage > | message | ||
) |
Handle the specified properties message.
Depending on the type of properties message(Get/Set/GetAll), the appropriate response will be built up and returned.
conn | The connection this is from |
message | The message with properties information |
References DBUSCXX_ERROR_PROPERTY_READ_ONLY, DBUSCXX_ERROR_UNKNOWN_PROPERTY, DBus::Handled, DBus::INVALID, LOGGER_NAME, DBus::ReadOnly, DBus::ReadWrite, SIMPLELOGGER_DEBUG, and DBus::WriteOnly.
bool DBus::Interface::has_method | ( | const std::string & | name | ) | const |
True if the interface has a method with the given name.
References name().
Referenced by add_method().
bool DBus::Interface::has_property | ( | const std::string & | name | ) | const |
References name().
Referenced by add_property().
bool DBus::Interface::has_signal | ( | const std::string & | name | ) | const |
True if this interface has at least one signal with the given name.
References name().
bool DBus::Interface::has_signal | ( | std::shared_ptr< SignalBase > | signal | ) | const |
True if the given signal is part of this interface.
References signal().
std::string DBus::Interface::introspect | ( | int | space_depth = 0 | ) | const |
std::shared_ptr< MethodBase > DBus::Interface::method | ( | const std::string & | name | ) | const |
Returns the method with the given name, or an invalid shared_ptr if not found.
References name().
Referenced by add_method(), create_method(), handle_call_message(), and remove_method().
const Interface::Methods & DBus::Interface::methods | ( | ) | const |
Returns the methods associated with this interface.
const std::string & DBus::Interface::name | ( | ) | const |
Get the name of this interface.
Referenced by add_signal(), create(), create_method(), create_property(), create_signal(), has_method(), has_property(), has_signal(), Interface(), introspect(), method(), remove_method(), and remove_signal().
Path DBus::Interface::path | ( | ) | const |
Returns the path of the object associated with this interface or a null string if no object is associated.
Referenced by add_signal(), and create_signal().
const std::set< std::shared_ptr< PropertyBase > > & DBus::Interface::properties | ( | ) |
|
private |
bool DBus::Interface::remove_method | ( | const std::string & | name | ) |
bool DBus::Interface::remove_method | ( | std::shared_ptr< MethodBase > | method | ) |
bool DBus::Interface::remove_signal | ( | const std::string & | name | ) |
Removes all signals with the given name.
References name().
bool DBus::Interface::remove_signal | ( | std::shared_ptr< SignalBase > | signal | ) |
Removes the given signal.
One reason a signal couldn't be removed is if it wasn't a part of the interface.
References signal().
|
private |
References signal().
|
private |
std::shared_ptr< SignalBase > DBus::Interface::signal | ( | const std::string & | signal_name | ) |
Returns the first signal found with a matching name.
If more than one signal has a given name there are no guarantees as to which signal will be returned.
Referenced by has_signal(), remove_signal(), and set_connection().
sigc::signal< void(std::shared_ptr< MethodBase >)> DBus::Interface::signal_method_added | ( | ) |
Signal emitted when a method of the given name is added.
sigc::signal< void(std::shared_ptr< MethodBase >)> DBus::Interface::signal_method_removed | ( | ) |
Signal emitted when a method of the given name is removed.
const Interface::Signals & DBus::Interface::signals | ( | ) |
Returns the signals associated with this interface.
|
friend |
|
friend |