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;
105  functor_type m_mem_func;
106 };
107 
108 
109 } // namespace sigx
110 
111 
112 #endif // _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
signal_source_pobj_mem_fun< T_obj, T_functor, T_signal > self_type
Definition: signal_source_obj_mem.h:89
signal_source_obj_mem(T_obj *_A_obj, typed_signal_ptr _A_sig)
Definition: signal_source_obj_mem.h:39
static T_signal get_signal(signal_source_ptr base)
Definition: signal_source_obj_mem.h:71
typed_signal_ptr m_sig
Definition: signal_source_obj_mem.h:79
signal source is a object's member function returning a signal of type T_signal. Object instance is l...
Definition: signal_source_obj_mem.h:87
sigc::functor_trait< T_functor >::functor_type functor_type
Definition: signal_source_obj_mem.h:90
Represents a source for any type of signal.
Definition: signal_source_base.h:38
void(* hook)()
An untyped function pointer.
Definition: signal_source_base.h:42
static T_signal get_signal(signal_source_ptr base)
Definition: signal_source_obj_mem.h:45
signal_source_pobj_mem_fun(T_obj *const &_A_obj, const T_functor &_A_mem_func)
Definition: signal_source_obj_mem.h:92
T_signal T_obj::* typed_signal_ptr
Definition: signal_source_obj_mem.h:37
signal_source_pobj_mem< T_obj, T_signal > self_type
Definition: signal_source_obj_mem.h:62
T_obj *const & m_obj
Definition: signal_source_obj_mem.h:78
Definition: auto_dispatchable.h:27
static T_signal get_signal(signal_source_ptr base)
Definition: signal_source_obj_mem.h:98
signal source is a object's member of type T_signal. Object instance is late bound.
Definition: signal_source_obj_mem.h:60
signal_source_pobj_mem(T_obj *const &_A_obj, typed_signal_ptr _A_sig)
Definition: signal_source_obj_mem.h:65
T_obj * m_obj
Definition: signal_source_obj_mem.h:52
signal_source_obj_mem< T_obj, T_signal > self_type
Definition: signal_source_obj_mem.h:36
signal source is a object's member of type T_signal.
Definition: signal_source_obj_mem.h:34
T_signal T_obj::* typed_signal_ptr
Definition: signal_source_obj_mem.h:63
T_obj *const & m_obj
Definition: signal_source_obj_mem.h:104
typed_signal_ptr m_sig
Definition: signal_source_obj_mem.h:53
functor_type m_mem_func
Definition: signal_source_obj_mem.h:105