27 #include <sigc++/sigc++.h>
29 #ifndef DBUSCXX_METHODBASE_H
30 #define DBUSCXX_METHODBASE_H
54 uint32_t
sendMessage( std::shared_ptr<Connection> connection,
const std::shared_ptr<const Message> );
59 const std::string&
name()
const;
64 virtual std::string
introspect(
int space_depth = 0 )
const {
return std::string(); };
66 std::string
arg_name(
size_t i )
const;
70 const std::vector<std::string>&
arg_names()
const;
78 template <
typename T_type>
84 static std::shared_ptr<Method<T_type>>
create(
const std::string&
name ) {
90 virtual std::string
introspect(
int space_depth = 0 )
const {
91 std::ostringstream sout;
95 for(
int i = 0; i < space_depth; i++ ) { spaces +=
" "; }
97 sout << spaces <<
"<method name=\"" <<
name() <<
"\">\n";
98 sout << method_sig_gen.introspect(
arg_names(), 0, spaces +
" " );
99 sout << spaces <<
"</method>\n";
104 std::ostringstream debug_str;
107 debug_str <<
"DBus::Method<";
108 debug_str << method_sig_gen.debug_string();
109 debug_str <<
">::handle_call_message method=";
116 std::shared_ptr<ReturnMessage> retmsg = message->create_reply();
120 method_sig_gen.extractAndCall( message, retmsg,
m_slot );
129 }
catch(
const std::exception& e ) {
136 std::ostringstream stream;
140 <<
": unknown error(uncaught exception)";
static std::shared_ptr< ErrorMessage > create()
Definition: errormessage.cpp:31
Base class for all methods(proxy and local).
Definition: methodbase.h:48
std::string arg_name(size_t i) const
Definition: methodbase.cpp:43
const std::vector< std::string > & arg_names() const
Definition: methodbase.cpp:56
virtual HandlerResult handle_call_message(std::shared_ptr< Connection > connection, std::shared_ptr< const CallMessage > message)=0
virtual std::string introspect(int space_depth=0) const
Returns a DBus XML description of this interface.
Definition: methodbase.h:64
MethodBase(const std::string &name)
Definition: methodbase.cpp:24
uint32_t sendMessage(std::shared_ptr< Connection > connection, const std::shared_ptr< const Message >)
Definition: methodbase.cpp:51
const std::string & name() const
Definition: methodbase.cpp:31
DBUS_CXX_PROPAGATE_CONST(std::unique_ptr< priv_data >) m_priv
void set_arg_name(size_t i, const std::string &name)
Definition: methodbase.cpp:35
virtual ~MethodBase()
Definition: methodbase.cpp:29
Definition: methodbase.h:79
static std::shared_ptr< Method< T_type > > create(const std::string &name)
Definition: methodbase.h:84
virtual std::string introspect(int space_depth=0) const
Definition: methodbase.h:90
Method(const std::string &name)
Definition: methodbase.h:81
void set_method(sigc::slot< T_type > slot)
Definition: methodbase.h:88
virtual HandlerResult handle_call_message(std::shared_ptr< Connection > connection, std::shared_ptr< const CallMessage > message)
Definition: methodbase.h:103
sigc::slot< T_type > m_slot
Definition: methodbase.h:153
#define DBUS_CXX_PACKAGE_MAJOR_VERSION
Definition: dbus-cxx-config.h:25
#define DBUS_CXX_PACKAGE_MINOR_VERSION
Definition: dbus-cxx-config.h:26
#define DBUS_CXX_PACKAGE_MICRO_VERSION
Definition: dbus-cxx-config.h:27
#define DBUSCXX_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
Definition: dbus-error.h:17
#define DBUSCXX_ERROR_INVALID_SIGNATURE
A type signature is not valid.
Definition: dbus-error.h:104
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
HandlerResult
Definition: enums.h:95
@ Not_Handled
This message was not handled for some reason.
@ Handled
This message was handled appropriately.
Definition: utility.h:234