00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the dbus-cxx library. * 00006 * * 00007 * The dbus-cxx library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The dbus-cxx library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef DBUSMETHODBASE_H 00020 #define DBUSMETHODBASE_H 00021 00022 #include <string> 00023 00024 #include <sigc++/sigc++.h> 00025 00026 #include <dbus-cxx/enums.h> 00027 #include <dbus-cxx/pointer.h> 00028 #include <dbus-cxx/accumulators.h> 00029 #include <dbus-cxx/callmessage.h> 00030 #include <dbus-cxx/returnmessage.h> 00031 00032 namespace DBus 00033 { 00034 class Connection; 00035 00036 class Interface; 00037 00045 // TODO fix signals that expect a return value and partially specialize for void returns 00046 00047 class MethodBase 00048 { 00049 protected: 00050 00051 MethodBase(const std::string& name); 00052 00053 MethodBase(const MethodBase& other); 00054 00055 public: 00056 00057 typedef DBusCxxPointer<MethodBase> pointer; 00058 00059 ~MethodBase(); 00060 00061 const std::string& name() const; 00062 00063 void set_name( const std::string& name ); 00064 00065 virtual HandlerResult handle_call_message( DBusCxxPointer<Connection> connection, CallMessage::const_pointer message ) = 0; 00066 00071 virtual pointer clone() = 0; 00072 00073 sigc::signal<void,const std::string&/*old name*/, const std::string&/*new name*/> signal_name_changed(); 00074 00076 virtual std::string introspect(int space_depth=0) const { return std::string(); } 00077 00078 virtual std::string arg_name(size_t i) { return std::string(); } 00079 00080 virtual void set_arg_name(size_t i, const std::string& name) { } 00081 00082 protected: 00083 00084 std::string m_name; 00085 00087 pthread_mutex_t m_name_mutex; 00088 00089 sigc::signal<void,const std::string&, const std::string&> m_signal_name_changed; 00090 00091 }; 00092 00435 } 00436 00437 #endif