adder_adapter.h
Go to the documentation of this file.00001 #ifndef __DBUS_ADAPTER_QUICKSTART_ADDER_H
00002 #define __DBUS_ADAPTER_QUICKSTART_ADDER_H
00003
00004 #include <dbus-cxx.h>
00005
00006 #include "adder.h"
00007
00008
00009 namespace Quickstart {
00010
00011 class AdderAdapter : public ::DBus::Object
00012 {
00013 protected:
00014 AdderAdapter( Quickstart::Adder* adaptee=NULL, const std::string& path="/dbuscxx/Adder"):
00015 ::DBus::Object(path),
00016 m_adaptee(adaptee)
00017 {
00018
00019 ::DBus::MethodBase::pointer temp_method;
00020
00021 temp_method = this->create_method<double,double,double>( "Quickstart.Adder", "add", sigc::mem_fun(*this, &AdderAdapter::add_adapter_stub_ddd) );
00022 temp_method->set_arg_name( 0, "result" );
00023 temp_method->set_arg_name( 1, "a" );
00024 temp_method->set_arg_name( 2, "b" );
00025 }
00026
00027 public:
00028
00029 typedef DBusCxxPointer<AdderAdapter> pointer;
00030
00031 static pointer create( Quickstart::Adder* adaptee=NULL, const std::string& path="/dbuscxx/Adder")
00032 { return pointer( new AdderAdapter(adaptee, path)); }
00033
00034 Quickstart::Adder* adaptee() { return m_adaptee; }
00035
00036 void set_adaptee( Quickstart::Adder* adaptee ) {
00037 m_adaptee = adaptee;
00038 }
00039
00040 void set_adaptee( Quickstart::Adder& adaptee ) {
00041 this->set_adaptee(&adaptee);
00042 }
00043
00044
00045 private:
00046
00047 Quickstart::Adder* m_adaptee;
00048
00049
00050 void check_adaptee() { if ( not m_adaptee) throw ::DBus::ErrorInvalidAdaptee::create(); }
00051
00052 double add_adapter_stub_ddd( double a, double b ) { this->check_adaptee(); return m_adaptee->add( a, b); }
00053
00054
00055 };
00056
00057 }
00058
00059 #endif