sigx++  2.0.1
signal_source_obj_mem.h
Go to the documentation of this file.
1 #ifndef _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
2 #define _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
3 
4 /*
5  * Copyright 2005 Klaus Triendl
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #include <sigc++/functors/functor_trait.h>
24 #include <sigxconfig.h>
26 
27 
28 namespace sigx
29 {
30 
33 template<typename T_obj, typename T_signal>
35 {
37  typedef T_signal T_obj::*typed_signal_ptr;
38 
39  signal_source_obj_mem(T_obj* _A_obj, typed_signal_ptr _A_sig):
40  signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
41  m_obj(_A_obj),
42  m_sig(_A_sig)
43  {}
44 
45  static T_signal get_signal(signal_source_ptr base)
46  {
47  self_type* const this_ = static_cast<self_type*>(base);
48  const typed_signal_ptr sig = this_->m_sig;
49  return this_->m_obj->*sig;
50  }
51 
52  T_obj* m_obj;
54 };
55 
59 template<typename T_obj, typename T_signal>
61 {
63  typedef T_signal T_obj::*typed_signal_ptr;
64 
65  signal_source_pobj_mem(T_obj* const& _A_obj, typed_signal_ptr _A_sig):
66  signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
67  m_obj(_A_obj),
68  m_sig(_A_sig)
69  {}
70 
71  static T_signal get_signal(signal_source_ptr base)
72  {
73  self_type* const this_ = static_cast<self_type*>(base);
74  const typed_signal_ptr sig = this_->m_sig;
75  return this_->m_obj->*sig;
76  }
77 
78  T_obj* const& m_obj;
80 };
81 
86 template<typename T_obj, typename T_functor, typename T_signal>
88 {
90  typedef typename sigc::functor_trait<T_functor>::functor_type functor_type;
91 
92  signal_source_pobj_mem_fun(T_obj* const& _A_obj, const T_functor& _A_mem_func):
93  signal_source_base(reinterpret_cast<hook>(&self_type::get_signal)),
94  m_obj(_A_obj),
95  m_mem_func(_A_mem_func)
96  {}
97 
98  static T_signal get_signal(signal_source_ptr base)
99  {
100  self_type* this_ = static_cast<self_type*>(base);
101  return this_->m_mem_func(this_->m_obj);
102  }
103 
104  T_obj* const& m_obj;
106 };
107 
108 
109 } // namespace sigx
110 
111 
112 #endif // _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_