signal_source_obj_mem.h
Go to the documentation of this file.00001 #ifndef _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
00002 #define _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <sigc++/functors/functor_trait.h>
00024 #include <sigxconfig.h>
00025 #include <sigx/signal_source_base.h>
00026
00027
00028 namespace sigx
00029 {
00030
00033 template<typename T_obj, typename T_signal>
00034 struct signal_source_obj_mem: public signal_source_base
00035 {
00036 typedef signal_source_obj_mem<T_obj, T_signal> self_type;
00037 typedef T_signal T_obj::*typed_signal_ptr;
00038
00039 signal_source_obj_mem(T_obj* _A_obj, typed_signal_ptr _A_sig):
00040 signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
00041 m_obj(_A_obj),
00042 m_sig(_A_sig)
00043 {}
00044
00045 static T_signal get_signal(signal_source_ptr base)
00046 {
00047 self_type* const this_ = static_cast<self_type*>(base);
00048 const typed_signal_ptr sig = this_->m_sig;
00049 return this_->m_obj->*sig;
00050 }
00051
00052 T_obj* m_obj;
00053 typed_signal_ptr m_sig;
00054 };
00055
00059 template<typename T_obj, typename T_signal>
00060 struct signal_source_pobj_mem: public signal_source_base
00061 {
00062 typedef signal_source_pobj_mem<T_obj, T_signal> self_type;
00063 typedef T_signal T_obj::*typed_signal_ptr;
00064
00065 signal_source_pobj_mem(T_obj* const& _A_obj, typed_signal_ptr _A_sig):
00066 signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
00067 m_obj(_A_obj),
00068 m_sig(_A_sig)
00069 {}
00070
00071 static T_signal get_signal(signal_source_ptr base)
00072 {
00073 self_type* const this_ = static_cast<self_type*>(base);
00074 const typed_signal_ptr sig = this_->m_sig;
00075 return this_->m_obj->*sig;
00076 }
00077
00078 T_obj* const& m_obj;
00079 typed_signal_ptr m_sig;
00080 };
00081
00086 template<typename T_obj, typename T_functor, typename T_signal>
00087 struct signal_source_pobj_mem_fun: public signal_source_base
00088 {
00089 typedef signal_source_pobj_mem_fun<T_obj, T_functor, T_signal> self_type;
00090 typedef typename sigc::functor_trait<T_functor>::functor_type functor_type;
00091
00092 signal_source_pobj_mem_fun(T_obj* const& _A_obj, const T_functor& _A_mem_func):
00093 signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
00094 m_obj(_A_obj),
00095 m_mem_func(_A_mem_func)
00096 {}
00097
00098 static T_signal get_signal(signal_source_ptr base)
00099 {
00100 self_type* this_ = static_cast<self_type*>(base);
00101 return this_->m_mem_func(this_->m_obj);
00102 }
00103
00104 T_obj* const& m_obj;
00105 functor_type m_mem_func;
00106 };
00107
00108
00109 }
00110
00111
00112 #endif // _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_