23 #ifndef _TelepathyQt_callbacks_h_HEADER_GUARD_ 24 #define _TelepathyQt_callbacks_h_HEADER_GUARD_ 26 #ifndef IN_TP_QT_HEADER 27 #error IN_TP_QT_HEADER 30 #include <TelepathyQt/Functors> 31 #include <TelepathyQt/Global> 38 typedef void *(*HookType)(
void*);
52 template <
class T,
class Functor>
73 bool isValid()
const {
return caller != 0; }
77 if (caller == other.
caller)
return *
this;
88 template <
class Functor,
class R >
99 Type *typed =
static_cast<Type*
>(call);
100 return (typed->functor)();
107 typedef R (*FunctionType)();
111 template <
class Functor>
118 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
119 return invokeMethod(caller );
125 template <
class Functor,
class R ,
class Arg1>
133 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1)
136 Type *typed =
static_cast<Type*
>(call);
137 return (typed->functor)(a1);
141 template <
class R ,
class Arg1>
144 typedef R (*FunctionType)(Arg1);
148 template <
class Functor>
155 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
156 return invokeMethod(caller , a1);
162 template <
class Functor,
class R ,
class Arg1,
class Arg2>
170 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2)
173 Type *typed =
static_cast<Type*
>(call);
174 return (typed->functor)(a1, a2);
178 template <
class R ,
class Arg1,
class Arg2>
181 typedef R (*FunctionType)(Arg1, Arg2);
185 template <
class Functor>
192 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
193 return invokeMethod(caller , a1, a2);
199 template <
class Functor,
class R ,
class Arg1,
class Arg2,
class Arg3>
207 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2, Arg3 a3)
210 Type *typed =
static_cast<Type*
>(call);
211 return (typed->functor)(a1, a2, a3);
215 template <
class R ,
class Arg1,
class Arg2,
class Arg3>
218 typedef R (*FunctionType)(Arg1, Arg2, Arg3);
222 template <
class Functor>
229 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
230 return invokeMethod(caller , a1, a2, a3);
236 template <
class Functor,
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
244 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
247 Type *typed =
static_cast<Type*
>(call);
248 return (typed->functor)(a1, a2, a3, a4);
252 template <
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
255 typedef R (*FunctionType)(Arg1, Arg2, Arg3, Arg4);
259 template <
class Functor>
262 ResultType
operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
const 266 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
267 return invokeMethod(caller , a1, a2, a3, a4);
273 template <
class Functor,
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
281 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5)
284 Type *typed =
static_cast<Type*
>(call);
285 return (typed->functor)(a1, a2, a3, a4, a5);
289 template <
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
292 typedef R (*FunctionType)(Arg1, Arg2, Arg3, Arg4, Arg5);
296 template <
class Functor>
299 ResultType
operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5)
const 303 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
304 return invokeMethod(caller , a1, a2, a3, a4, a5);
310 template <
class Functor,
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6>
318 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6)
321 Type *typed =
static_cast<Type*
>(call);
322 return (typed->functor)(a1, a2, a3, a4, a5, a6);
326 template <
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6>
329 typedef R (*FunctionType)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
333 template <
class Functor>
336 ResultType
operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6)
const 340 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
341 return invokeMethod(caller , a1, a2, a3, a4, a5, a6);
347 template <
class Functor,
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6,
class Arg7>
353 explicit FunctorCaller7(
const Functor &functor) :
BaseFunctorCaller<
FunctorCaller7, Functor>(functor, reinterpret_cast<AbstractFunctorCaller::HookType>(&
FunctorCaller7<Functor, R , Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>::invoke)) {}
355 static ResultType
invoke(AbstractFunctorCaller *call , Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6, Arg7 a7)
358 Type *typed =
static_cast<Type*
>(call);
359 return (typed->functor)(a1, a2, a3, a4, a5, a6, a7);
363 template <
class R ,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6,
class Arg7>
366 typedef R (*FunctionType)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7);
370 template <
class Functor>
373 ResultType
operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6, Arg7 a7)
const 377 InvokeType invokeMethod =
reinterpret_cast<InvokeType
>(caller->invokeMethodHook);
378 return invokeMethod(caller , a1, a2, a3, a4, a5, a6, a7);
BaseCallback(const BaseCallback &other)
Definition: callbacks.h:70
R ResultType
Definition: callbacks.h:165
BaseCallback(AbstractFunctorCaller *caller)
Definition: callbacks.h:69
virtual ~BaseFunctorCaller()
Definition: callbacks.h:58
Callback with 1 argument.
Definition: callbacks.h:142
HookType invokeMethodHook
Definition: callbacks.h:45
R ResultType
Definition: callbacks.h:219
Callback2()
Definition: callbacks.h:184
Definition: callbacks.h:237
R ResultType
Definition: callbacks.h:350
Callback with 6 arguments.
Definition: callbacks.h:327
R ResultType
Definition: callbacks.h:108
Definition: callbacks.h:36
Callback3()
Definition: callbacks.h:221
Definition: callbacks.h:348
Callback5(const Functor &functor)
Definition: callbacks.h:297
Callback6(const Functor &functor)
Definition: callbacks.h:334
Definition: callbacks.h:53
BaseCallback & operator=(const BaseCallback &other)
Definition: callbacks.h:75
ResultType operator()(Arg1 a1) const
Definition: callbacks.h:151
R ResultType
Definition: callbacks.h:91
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6)
Definition: callbacks.h:318
Callback0()
Definition: callbacks.h:110
Functor functor
Definition: callbacks.h:62
R ResultType
Definition: callbacks.h:128
Definition: callbacks.h:89
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1)
Definition: callbacks.h:133
AbstractFunctorCaller(HookType invokeMethodHook)
Definition: callbacks.h:40
virtual AbstractFunctorCaller * clone() const =0
R ResultType
Definition: callbacks.h:313
R ResultType
Definition: callbacks.h:293
BaseFunctorCaller(const Functor &functor, AbstractFunctorCaller::HookType invokeMethodHook)
Definition: callbacks.h:55
void *(* HookType)(void *)
Definition: callbacks.h:38
Callback3(const Functor &functor)
Definition: callbacks.h:223
ResultType operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4) const
Definition: callbacks.h:262
virtual AbstractFunctorCaller * clone() const
Definition: callbacks.h:60
Definition: callbacks.h:311
FunctorCaller5(const Functor &functor)
Definition: callbacks.h:279
FunctorCaller1(const Functor &functor)
Definition: callbacks.h:131
R ResultType
Definition: callbacks.h:276
static ResultType invoke(AbstractFunctorCaller *call)
Definition: callbacks.h:96
ResultType operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5) const
Definition: callbacks.h:299
Callback1()
Definition: callbacks.h:147
Definition: callbacks.h:200
Callback with 0 arguments.
Definition: callbacks.h:105
Callback6()
Definition: callbacks.h:332
Callback with 5 arguments.
Definition: callbacks.h:290
Callback with 3 arguments.
Definition: callbacks.h:216
ResultType operator()(Arg1 a1, Arg2 a2, Arg3 a3) const
Definition: callbacks.h:225
FunctorCaller7(const Functor &functor)
Definition: callbacks.h:353
Callback2(const Functor &functor)
Definition: callbacks.h:186
ResultType operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6, Arg7 a7) const
Definition: callbacks.h:373
Callback7()
Definition: callbacks.h:369
FunctorCaller3(const Functor &functor)
Definition: callbacks.h:205
Base class for all the callback classes.
Definition: callbacks.h:65
Definition: callbacks.h:163
virtual ~BaseCallback()
Definition: callbacks.h:71
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2)
Definition: callbacks.h:170
Callback0(const Functor &functor)
Definition: callbacks.h:112
ResultType operator()(Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6) const
Definition: callbacks.h:336
Callback with 4 arguments.
Definition: callbacks.h:253
Definition: callbacks.h:274
Callback with 2 arguments.
Definition: callbacks.h:179
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5, Arg6 a6, Arg7 a7)
Definition: callbacks.h:355
bool isValid() const
Definition: callbacks.h:73
R ResultType
Definition: callbacks.h:239
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4, Arg5 a5)
Definition: callbacks.h:281
Callback4(const Functor &functor)
Definition: callbacks.h:260
Callback4()
Definition: callbacks.h:258
Definition: abstract-adaptor.cpp:31
ResultType operator()() const
Definition: callbacks.h:114
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
Definition: callbacks.h:244
ResultType operator()(Arg1 a1, Arg2 a2) const
Definition: callbacks.h:188
R ResultType
Definition: callbacks.h:182
FunctorCaller0(const Functor &functor)
Definition: callbacks.h:94
Callback1(const Functor &functor)
Definition: callbacks.h:149
Callback7(const Functor &functor)
Definition: callbacks.h:371
static ResultType invoke(AbstractFunctorCaller *call, Arg1 a1, Arg2 a2, Arg3 a3)
Definition: callbacks.h:207
FunctorCaller6(const Functor &functor)
Definition: callbacks.h:316
Callback5()
Definition: callbacks.h:295
Callback with 7 arguments.
Definition: callbacks.h:364
R ResultType
Definition: callbacks.h:145
R ResultType
Definition: callbacks.h:330
R ResultType
Definition: callbacks.h:202
AbstractFunctorCaller * caller
Definition: callbacks.h:85
BaseCallback()
Definition: callbacks.h:67
R ResultType
Definition: callbacks.h:367
FunctorCaller2(const Functor &functor)
Definition: callbacks.h:168
R ResultType
Definition: callbacks.h:256
FunctorCaller4(const Functor &functor)
Definition: callbacks.h:242
virtual ~AbstractFunctorCaller()
Definition: callbacks.h:41
Definition: callbacks.h:126