sigx++  2.0.1
internal_types.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /* Do not edit! -- generated file */
3 
4 
5 #ifndef _SIGXMACROS_INTERNAL_TYPES_H_
6 #define _SIGXMACROS_INTERNAL_TYPES_H_
7 
8 
9 /*
10  * Copyright 2007 Klaus Triendl
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26 
27 #include <sigc++/type_traits.h> // sigc::is_base_and_derived
28 #include <sigc++/functors/functor_trait.h> // sigc::nil
29 #include <sigc++/adaptors/deduce_result_type.h> // sigc::adaptor_base
30 #include <sigc++/adaptors/adaptor_trait.h> // sigc::adaptor_functor
31 #include <sigc++/adaptors/bind.h> // sigc::bind_functor
32 #include <sigc++/adaptors/hide.h> // sigc::hide_functor
33 #include <sigc++/functors/slot_base.h> // sigc::slot_base
34 #include <sigx/fwddecl.h>
35 #include <sigx/types.h>
36 #include <sigx/static_assert.h>
37 
38 
39 // functor attaching a shared_dispatchable to another functor by binding
40 // the shared_dispatchable and hiding it
41 #define SIGX_DISPATCH_WITH_FUNCTOR(T_functor)\
42  sigc::bind_functor<-1, sigc::hide_functor<-1, T_functor>, shared_dispatchable>
43 
44 
45 namespace sigx
46 {
47 
48  namespace internal
49  {
50 
51 
55 template <typename T_arg1 = sigc::nil, typename T_arg2 = sigc::nil, typename T_arg3 = sigc::nil, typename T_arg4 = sigc::nil, typename T_arg5 = sigc::nil, typename T_arg6 = sigc::nil, typename T_arg7 = sigc::nil>
57  { static const int value = 7; };
58 
59 template <>
61  { static const int value = 0; };
62 template <typename T_arg1>
63 struct count_arguments<T_arg1>
64  { static const int value = 1; };
65 template <typename T_arg1, typename T_arg2>
66 struct count_arguments<T_arg1, T_arg2>
67  { static const int value = 2; };
68 template <typename T_arg1, typename T_arg2, typename T_arg3>
69 struct count_arguments<T_arg1, T_arg2, T_arg3>
70  { static const int value = 3; };
71 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
72 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4>
73  { static const int value = 4; };
74 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
75 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>
76  { static const int value = 5; };
77 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
78 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>
79  { static const int value = 6; };
80 
81 
82 
94 template<typename T_functor,
95 bool I_istunnel =
96  sigc::is_base_and_derived<sigx::tunnel_base, T_functor>::value,
97 bool I_isadaptor =
98  sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
100 
101 
105 template<typename T_functor>
106 struct is_functor_tunneled<T_functor, true, true>
107 {
108  static const bool value = true;
109 };
110 
114 template<typename T_functor>
115 struct is_functor_tunneled<T_functor, true, false>
116 {
117  static const bool value = true;
118 };
119 
124 template<typename T_functor>
125 struct is_functor_tunneled<T_functor, false, false>
126 {
127  // no chance to investigate further, probably a static or member function
128  // pointer
129  static const bool value = false;
130 };
131 
135 template<typename T_functor>
136 struct is_functor_tunneled<T_functor, false, true>
137 {
138  // investigate further by cascading the functor chain
139  // functor must define adaptor_type;
140  // T_functor is probably derived from sigc::adapts<T_functor>; defines
141  // adaptor_type
142  typedef typename T_functor::adaptor_type adaptor_type;
143  static const bool value = is_functor_tunneled<adaptor_type>::value;
144 };
145 
152 template<typename T_functor>
153 struct is_functor_tunneled<sigc::adaptor_functor<T_functor>, false, true>
154 {
155  static const bool value = is_functor_tunneled<T_functor>::value;
156 };
157 
158 
159 
160 
172 template<
173  typename T_functor,
174  bool I_isslot = sigc::is_base_and_derived<sigc::slot_base, T_functor>::value,
175  bool I_isadaptor = sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
177 
178 
182 template<typename T_functor>
183 struct is_or_adapts_slot<T_functor, true, false>
184 {
185  static const bool value = true;
186 };
187 
192 template<typename T_functor>
193 struct is_or_adapts_slot<T_functor, false, false>
194 {
195  // no chance to investigate further, probably a static or member function
196  // pointer
197  static const bool value = false;
198 };
199 
203 template<typename T_functor>
204 struct is_or_adapts_slot<T_functor, false, true>
205 {
206  // investigate further by cascading the functor chain
207  // functor must define adaptor_type;
208  // T_functor is probably derived from sigc::adapts<T_functor>; defines
209  // adaptor_type
210  typedef typename T_functor::adaptor_type adaptor_type;
211  static const bool value = is_or_adapts_slot<adaptor_type>::value;
212 };
213 
220 template<typename T_functor>
221 struct is_or_adapts_slot<sigc::adaptor_functor<T_functor>, false, true>
222 {
223  static const bool value = is_or_adapts_slot<T_functor>::value;
224 };
225 
226 
227 
228 
239 template<typename T_functor, bool I_isadapter = sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
241 
242 
243 template<typename T_functor>
244 struct dispatchable_constraint<T_functor, false>
245 {
246  static const dispatchable& find_dispatchable(typename sigc::type_trait<T_functor>::take _A_func)
247  {
248  // if the compiler reports an error there are only 2 possibilities:
249  // 1) you connected a static function to a signal or opened a tunnel on a
250  // static signal without specifying the dispatchable to operate on.
251  // 2) you connected a member function to a signal or opened a tunnel on a
252  // member function where the member function is not from a dispatchable
253  // solution: call 'open_tunnel_with' or 'open_sync_tunnel_with' and specify the dispatachable!
254 
255  // access obj_ of the functor;
256  // this issues a compile time error if _A_func is not a functor
257  // on an object's member function (only sigc member functors have this)
258  // obj_ is a (const_)limit_reference type; must call invoke() to
259  // ensure that we get the bound member type instead of a sigc::trackable
260  return _A_func.obj_.invoke();
261  }
262 };
263 
264 // walks down the adaptor chain
265 template<typename T_functor>
266 struct dispatchable_constraint<T_functor, true>
267 {
268  static const dispatchable& find_dispatchable(typename sigc::type_trait<T_functor>::take _A_func)
269  {
270  return is_adaptor_dispatchable(_A_func);
271  }
272 
273 private:
274  // takes T_functor and matches it again to find
275  // special types and walk down the adaptor chain
276  template<typename T_adapted_functor>
277  static const dispatchable& is_adaptor_dispatchable(const sigc::adaptor_functor<T_adapted_functor>& _A_func)
278  {
280  }
281 
282  // match the sigx special dispatchable adaptor chain
283  template<typename T_adapted_functor>
284  static const dispatchable& is_adaptor_dispatchable(const SIGX_DISPATCH_WITH_FUNCTOR(T_adapted_functor)& _A_func)
285  {
286  // no need to proceed as we found out that the functor is dispatchable
287  return _A_func.bound1_.visit();
288  }
289 
290  // match all other apaptors, must define adaptor_type
291  template<typename T_adapted_functor>
292  static const dispatchable& is_adaptor_dispatchable(const T_adapted_functor& _A_func)
293  {
294  // T_adapted_functor must define adaptor_type;
295  typedef typename T_adapted_functor::adaptor_type adaptor_type;
296  // _A_func.functor_ is always an adaptor_type
297  return is_adaptor_dispatchable(_A_func.functor_);
298  }
299 };
300 
301 
302  } // namespace internal
303 
304 } // namespace sigx
305 #endif /* _SIGXMACROS_INTERNAL_TYPES_H_ */