sigx++  2.0.1
signal_f.h
Go to the documentation of this file.
1 #ifndef _SIGX_SIGNAL_F_HPP_
2 #define _SIGX_SIGNAL_F_HPP_
3 
4 /*
5  * Copyright 2006 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++/signal.h>
24 #include <sigxconfig.h>
25 #include <sigx/fwddecl.h>
26 #include <sigx/tunnel_functor.h>
32 #include <sigx/signal_wrapper.h>
33 #include <sigx/signal_f_base.h>
34 
35 
36 namespace sigx
37 {
38 
120 template<typename T_signal>
121 class signal_f: protected signal_f_base
122 {
123 public:
124  typedef T_signal signal_type;
126 
133  template<typename T_threadpriv>
134  signal_f(const shared_dispatchable& _A_disp, Glib::Private<T_threadpriv>& _A_priv, signal_type T_threadpriv::*_A_sig):
135  signal_f_base(_A_disp,
136  new signal_source_threadprivate<T_threadpriv, T_signal>(_A_priv, _A_sig))
137  {}
138 
145  template<typename T_dispatchable>
146  signal_f(T_dispatchable& _A_obj, signal_type T_dispatchable::*_A_sig):
147  signal_f_base(_A_obj,
148  new signal_source_obj_mem<T_dispatchable, signal_type>(&_A_obj, _A_sig))
149  {}
150 
157  template<typename T_obj>
158  signal_f(const shared_dispatchable& _A_disp, T_obj& _A_obj, signal_type T_obj::*_A_sig):
159  signal_f_base(_A_disp,
160  new signal_source_obj_mem<T_obj, signal_type>(&_A_obj, _A_sig))
161  {}
162 
170  template<typename T_obj>
171  signal_f(const shared_dispatchable& _A_disp, sigc::const_reference_wrapper<T_obj*> _A_obj, signal_type T_obj::*_A_sig):
172  signal_f_base(_A_disp,
173  new signal_source_obj_mem<const T_obj, signal_type>(sigc::unwrap(_A_obj), _A_sig))
174  {}
175  template<typename T_obj>
176  signal_f(const shared_dispatchable& _A_disp, sigc::reference_wrapper<T_obj*> _A_obj, signal_type T_obj::*_A_sig):
177  signal_f_base(_A_disp,
178  new signal_source_obj_mem<T_obj, signal_type>(sigc::unwrap(_A_obj), _A_sig))
179  {}
180 
190  template<typename T_obj, typename T_functor>
191  signal_f(const shared_dispatchable& _A_disp, sigc::const_reference_wrapper<T_obj*> _A_obj, const T_functor& _A_sig_func):
192  signal_f_base(_A_disp,
193  new signal_source_pobj_mem_fun<const T_obj, T_functor, signal_type>(sigc::unwrap(_A_obj), _A_sig_func))
194  {}
195  template<typename T_obj, typename T_functor>
196  signal_f(const shared_dispatchable& _A_disp, sigc::reference_wrapper<T_obj*> _A_obj, const T_functor& _A_sig_func):
197  signal_f_base(_A_disp,
198  new signal_source_pobj_mem_fun<T_obj, T_functor, signal_type>(sigc::unwrap(_A_obj), _A_sig_func))
199  {}
200 
206  template<typename T_functor>
207  signal_f(const shared_dispatchable& _A_disp, const T_functor& _A_sig_func):
208  signal_f_base(_A_disp,
209  new signal_source_func<T_functor, signal_type>(_A_sig_func))
210  {}
211 
218  template<typename T_functor>
219  explicit signal_f(const T_functor& _A_sig_func):
220  signal_f_base(internal::dispatchable_constraint<T_functor>::find_dispatchable(_A_sig_func),
221  new signal_source_func<T_functor, signal_type>(_A_sig_func))
222  {}
223 
227  signal_wrapper<signal_type> operator ()() const
228  {
229  return signal_wrapper<signal_type>(m_disp, m_sigsource);
230  }
231 };
232 
233 
234 } // namespace sigx
235 
236 
237 #endif // end file guard