00001
00002
00003
00004
00005 #ifndef _SIGXMACROS_INTERNAL_TYPES_H_
00006 #define _SIGXMACROS_INTERNAL_TYPES_H_
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <sigc++/type_traits.h>
00028 #include <sigc++/functors/functor_trait.h>
00029 #include <sigc++/adaptors/deduce_result_type.h>
00030 #include <sigc++/adaptors/adaptor_trait.h>
00031 #include <sigc++/adaptors/bind.h>
00032 #include <sigc++/adaptors/hide.h>
00033 #include <sigc++/functors/slot_base.h>
00034 #include <sigx/fwddecl.h>
00035 #include <sigx/types.h>
00036 #include <sigx/static_assert.h>
00037
00038
00039
00040
00041 #define SIGX_DISPATCH_WITH_FUNCTOR(T_functor)\
00042 sigc::bind_functor<-1, sigc::hide_functor<-1, T_functor>, shared_dispatchable>
00043
00044
00045 namespace sigx
00046 {
00047
00048 namespace internal
00049 {
00050
00051
00055 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>
00056 struct count_arguments
00057 { static const int value = 7; };
00058
00059 template <>
00060 struct count_arguments<>
00061 { static const int value = 0; };
00062 template <typename T_arg1>
00063 struct count_arguments<T_arg1>
00064 { static const int value = 1; };
00065 template <typename T_arg1, typename T_arg2>
00066 struct count_arguments<T_arg1, T_arg2>
00067 { static const int value = 2; };
00068 template <typename T_arg1, typename T_arg2, typename T_arg3>
00069 struct count_arguments<T_arg1, T_arg2, T_arg3>
00070 { static const int value = 3; };
00071 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
00072 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4>
00073 { static const int value = 4; };
00074 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
00075 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>
00076 { static const int value = 5; };
00077 template <typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
00078 struct count_arguments<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>
00079 { static const int value = 6; };
00080
00081
00082
00094 template<typename T_functor,
00095 bool I_istunnel =
00096 sigc::is_base_and_derived<sigx::tunnel_base, T_functor>::value,
00097 bool I_isadaptor =
00098 sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
00099 struct is_functor_tunneled;
00100
00101
00105 template<typename T_functor>
00106 struct is_functor_tunneled<T_functor, true, true>
00107 {
00108 static const bool value = true;
00109 };
00110
00114 template<typename T_functor>
00115 struct is_functor_tunneled<T_functor, true, false>
00116 {
00117 static const bool value = true;
00118 };
00119
00124 template<typename T_functor>
00125 struct is_functor_tunneled<T_functor, false, false>
00126 {
00127
00128
00129 static const bool value = false;
00130 };
00131
00135 template<typename T_functor>
00136 struct is_functor_tunneled<T_functor, false, true>
00137 {
00138
00139
00140
00141
00142 typedef typename T_functor::adaptor_type adaptor_type;
00143 static const bool value = is_functor_tunneled<adaptor_type>::value;
00144 };
00145
00152 template<typename T_functor>
00153 struct is_functor_tunneled<sigc::adaptor_functor<T_functor>, false, true>
00154 {
00155 static const bool value = is_functor_tunneled<T_functor>::value;
00156 };
00157
00158
00159
00160
00172 template<
00173 typename T_functor,
00174 bool I_isslot = sigc::is_base_and_derived<sigc::slot_base, T_functor>::value,
00175 bool I_isadaptor = sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
00176 struct is_or_adapts_slot;
00177
00178
00182 template<typename T_functor>
00183 struct is_or_adapts_slot<T_functor, true, false>
00184 {
00185 static const bool value = true;
00186 };
00187
00192 template<typename T_functor>
00193 struct is_or_adapts_slot<T_functor, false, false>
00194 {
00195
00196
00197 static const bool value = false;
00198 };
00199
00203 template<typename T_functor>
00204 struct is_or_adapts_slot<T_functor, false, true>
00205 {
00206
00207
00208
00209
00210 typedef typename T_functor::adaptor_type adaptor_type;
00211 static const bool value = is_or_adapts_slot<adaptor_type>::value;
00212 };
00213
00220 template<typename T_functor>
00221 struct is_or_adapts_slot<sigc::adaptor_functor<T_functor>, false, true>
00222 {
00223 static const bool value = is_or_adapts_slot<T_functor>::value;
00224 };
00225
00226
00227
00228
00239 template<typename T_functor, bool I_isadapter = sigc::is_base_and_derived<sigc::adaptor_base, T_functor>::value>
00240 struct dispatchable_constraint;
00241
00242
00243 template<typename T_functor>
00244 struct dispatchable_constraint<T_functor, false>
00245 {
00246 static const dispatchable& find_dispatchable(typename sigc::type_trait<T_functor>::take _A_func)
00247 {
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 return _A_func.obj_.invoke();
00261 }
00262 };
00263
00264
00265 template<typename T_functor>
00266 struct dispatchable_constraint<T_functor, true>
00267 {
00268 static const dispatchable& find_dispatchable(typename sigc::type_trait<T_functor>::take _A_func)
00269 {
00270 return is_adaptor_dispatchable(_A_func);
00271 }
00272
00273 private:
00274
00275
00276 template<typename T_adapted_functor>
00277 static const dispatchable& is_adaptor_dispatchable(const sigc::adaptor_functor<T_adapted_functor>& _A_func)
00278 {
00279 return dispatchable_constraint<T_adapted_functor>::find_dispatchable(_A_func.functor_);
00280 }
00281
00282
00283 template<typename T_adapted_functor>
00284 static const dispatchable& is_adaptor_dispatchable(const SIGX_DISPATCH_WITH_FUNCTOR(T_adapted_functor)& _A_func)
00285 {
00286
00287 return _A_func.bound1_.visit();
00288 }
00289
00290
00291 template<typename T_adapted_functor>
00292 static const dispatchable& is_adaptor_dispatchable(const T_adapted_functor& _A_func)
00293 {
00294
00295 typedef typename T_adapted_functor::adaptor_type adaptor_type;
00296
00297 return is_adaptor_dispatchable(_A_func.functor_);
00298 }
00299 };
00300
00301
00302 }
00303
00304 }
00305 #endif