21 #ifndef STATIC_ASSERT_H
32 template<
typename RT,
typename P1,
typename P2,
typename P3>
35 typedef RT (*
Type)(P1,P2,P3);
38 template<
typename RT,
typename P1,
typename P2>
43 template<
typename RT,
typename P1>
83 template<>
class ConstParamT<void> {
class Unused {};
public:
typedef Unused
Type; };
90 #define INVALID_CB_PARAM_TYPE(TYPE) template<> class AW_CL_castableType<TYPE> { }
96 #undef INVALID_CB_PARAM_TYPE
101 template<
typename RT,
typename P1 =
void,
typename P2 =
void,
typename P3 =
void>
117 RT
operator()(FP1 p1, FP2 p2, FP3 p3)
const {
return cb(p1, p2, p3); }
136 template<
typename P1,
typename P2>
148 return p1<other.
p1 || (p1 == other.
p1 && (p2< other.
p2 || (p2 == other.
p2 && dealloc<other.
dealloc)));
151 return p1 == other.
p1 && p2 == other.
p2 && dealloc == other.
dealloc;
160 template<
typename RT>
184 template<
typename RT,
typename FIXED>
208 template<
typename RT,
typename F1,
typename F2>
221 cd(new FFV_CallbackData(P, 0))
232 template<
typename RT,
typename F1,
typename F2>
239 enum funtype { ST_P0F12, ST_P0F2, ST_P1 };
245 funtype get_funtype()
const {
return cd->
p2; }
248 Callback_FVF(SigP0F12 CB) : cb(CB.get_cb()), cd(new FVF_CallbackData(0, ST_P0F12)) {}
249 Callback_FVF(SigP0F2 CB) : cb(CB.get_cb()), cd(new FVF_CallbackData(0, ST_P0F2)) {}
253 cd(new FVF_CallbackData(P1, ST_P1,
CASTSIG(typename FVF_CallbackData::CallbackDataDeallocator, dealloc)))
257 funtype ft = get_funtype();
278 #define CASTABLE_TO_AW_CL(TYPE) (sizeof(TYPE) <= sizeof(AW_CL))
279 #define CAST_TO_AW_CL(TYPE,PARAM) AW_CL_castableType<TYPE>::cast_to_AW_CL(PARAM)
281 #define CONST_PARAM_T(T) typename ConstParamT<T>::Type
283 #define CAST_DEALLOCATOR(dealloc) CASTSIG(UntypedCallbackData::CallbackDataDeallocator,dealloc)
288 #define CBTYPE_VV_BUILDER_P1(BUILDER,CB,RESULT,SIG,P1,P1fun) \
289 template<typename P1> \
290 inline CB BUILDER(RESULT (*cb)(P1fun), P1 p1) { \
291 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
292 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1), 0); \
294 template<typename P1> \
295 inline CB BUILDER(RESULT (*cb)(P1fun), \
296 void (*dealloc)(P1), P1 p1) { \
297 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
298 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1), 0); \
301 #define CBTYPE_VV_BUILDER_P1P2(BUILDER,CB,RESULT,SIG,P1,P2,P1fun,P2fun) \
302 template<typename P1, typename P2> \
303 inline CB BUILDER(RESULT (*cb)(P1fun, P2fun), \
305 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1) && CASTABLE_TO_AW_CL(P2)); \
306 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1), CAST_TO_AW_CL(P2,p2)); \
308 template<typename P1, typename P2> \
309 inline CB BUILDER(RESULT (*cb)(P1fun, P2fun), \
310 void (*dealloc)(P1,P2), P1 p1, P2 p2) { \
311 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1) && CASTABLE_TO_AW_CL(P2)); \
312 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1), CAST_TO_AW_CL(P2,p2)); \
315 #define CBTYPE_VV_BUILDER_NP12(BUILDER,CB,RESULT,SIG,P1,P2) \
316 CBTYPE_VV_BUILDER_P1(BUILDER,CB,RESULT,SIG,P1,P1); \
317 CBTYPE_VV_BUILDER_P1(BUILDER,CB,RESULT,SIG,P1,CONST_PARAM_T(P1)); \
318 CBTYPE_VV_BUILDER_P1P2(BUILDER,CB,RESULT,SIG,P1,P2,P1,P2); \
319 CBTYPE_VV_BUILDER_P1P2(BUILDER,CB,RESULT,SIG,P1,P2,P1,CONST_PARAM_T(P2)); \
320 CBTYPE_VV_BUILDER_P1P2(BUILDER,CB,RESULT,SIG,P1,P2,CONST_PARAM_T(P1),P2); \
321 CBTYPE_VV_BUILDER_P1P2(BUILDER,CB,RESULT,SIG,P1,P2,CONST_PARAM_T(P1),CONST_PARAM_T(P2))
323 #define CBTYPE_VV_BUILDER_TEMPLATES(BUILDER,CB,RESULT,SIG) \
324 inline CB BUILDER(RESULT (*cb)()) { \
325 return CB(CASTSIG(SIG,cb), 0, 0); \
327 CBTYPE_VV_BUILDER_NP12(BUILDER,CB,RESULT,SIG,P1,P2)
332 #define CBTYPE_FVV_BUILDER_NP(BUILDER,CB,RESULT,FIXED,SIG) \
333 inline CB BUILDER(RESULT (*cb)(FIXED)) { \
334 return CB((SIG)(void*)cb, 0, 0); \
338 #define CBTYPE_FVV_BUILDER_P1(BUILDER,CB,RESULT,FIXED,SIG,P1,P1fun) \
339 template<typename P1> \
340 inline CB BUILDER(RESULT (*cb)(FIXED, P1fun), P1 p1) { \
341 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
342 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1), 0); \
344 template<typename P1> \
345 inline CB BUILDER(RESULT (*cb)(FIXED, P1fun), \
346 void (*dealloc)(P1), P1 p1) { \
347 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
348 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1), 0); \
351 #define CBTYPE_FVV_BUILDER_P1P2(BUILDER,CB,RESULT,FIXED,SIG,P1,P2,P1fun,P2fun) \
352 template<typename P1, typename P2> \
353 inline CB BUILDER(RESULT (*cb)(FIXED, P1fun, P2fun), \
355 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1) && CASTABLE_TO_AW_CL(P2)); \
356 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1), CAST_TO_AW_CL(P2,p2)); \
358 template<typename P1, typename P2> \
359 inline CB BUILDER(RESULT (*cb)(FIXED, P1fun, P2fun), \
360 void (*dealloc)(P1,P2), P1 p1, P2 p2) { \
361 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1) && CASTABLE_TO_AW_CL(P2)); \
362 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1), CAST_TO_AW_CL(P2,p2)); \
365 #define CBTYPE_FVV_BUILDER_NP12(BUILDER,CB,RESULT,FIXED,SIG,P1,P2) \
366 CBTYPE_FVV_BUILDER_NP(BUILDER,CB,RESULT,FIXED,SIG); \
367 CBTYPE_FVV_BUILDER_P1(BUILDER,CB,RESULT,FIXED,SIG,P1,P1); \
368 CBTYPE_FVV_BUILDER_P1(BUILDER,CB,RESULT,FIXED,SIG,P1,CONST_PARAM_T(P1)); \
369 CBTYPE_FVV_BUILDER_P1P2(BUILDER,CB,RESULT,FIXED,SIG,P1,P2,P1,P2); \
370 CBTYPE_FVV_BUILDER_P1P2(BUILDER,CB,RESULT,FIXED,SIG,P1,P2,P1,CONST_PARAM_T(P2)); \
371 CBTYPE_FVV_BUILDER_P1P2(BUILDER,CB,RESULT,FIXED,SIG,P1,P2,CONST_PARAM_T(P1),P2); \
372 CBTYPE_FVV_BUILDER_P1P2(BUILDER,CB,RESULT,FIXED,SIG,P1,P2,CONST_PARAM_T(P1),CONST_PARAM_T(P2))
374 #define CBTYPE_FVV_BUILDER_TEMPLATES(BUILDER,CB,RESULT,FIXED,SIG) \
375 inline CB BUILDER(RESULT (*cb)()) { \
376 return CB(CASTSIG(SIG,cb), 0, 0); \
378 CBTYPE_FVV_BUILDER_NP12(BUILDER,CB,RESULT,FIXED,SIG,P1,P2); \
379 CBTYPE_FVV_BUILDER_NP12(BUILDER,CB,RESULT,UNFIXED,SIG,P1,P2)
381 #define CBTYPE_FVV_BUILDER_P(BUILDER,CB,RESULT,F1,F2,SIG,P,Pfun) \
382 template<typename P> \
383 inline CB BUILDER(RESULT (*cb)(F1,F2,Pfun), P p) { \
384 STATIC_ASSERT(CASTABLE_TO_AW_CL(P)); \
385 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P,p)); \
387 template<typename P> \
388 inline CB BUILDER(RESULT (*cb)(F1,F2,Pfun), void (*dealloc)(P), P p) { \
389 STATIC_ASSERT(CASTABLE_TO_AW_CL(P)); \
390 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P,p)); \
396 #define CBTYPE_FFV_BUILDER_TEMPLATES(BUILDER,CB,RESULT,F1,F2,SIG) \
397 inline CB BUILDER(RESULT (*cb)()) { return CB(CASTSIG(SIG,cb), 0); } \
398 inline CB BUILDER(RESULT (*cb)(F1)) { return CB(CASTSIG(SIG,cb), 0); } \
399 inline CB BUILDER(RESULT (*cb)(F1,F2)) { return CB(CASTSIG(SIG,cb), 0); } \
400 CBTYPE_FVV_BUILDER_P(BUILDER,CB,RESULT,F1,F2,SIG,P,P); \
401 CBTYPE_FVV_BUILDER_P(BUILDER,CB,RESULT,F1,F2,SIG,P,CONST_PARAM_T(P))
406 #define CBTYPE_FVF_BUILDER_P1_F1F2(BUILDER,CB,RESULT,F1,F2,SIG,P1,P1fun) \
407 template<typename P1> \
408 inline CB BUILDER(RESULT (*cb)(F1, P1fun, F2), P1 p1) { \
409 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
410 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1)); \
412 template<typename P1> \
413 inline CB BUILDER(RESULT (*cb)(F1, P1fun, F2), \
414 void (*dealloc)(P1), P1 p1) { \
415 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
416 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1)); \
419 #define CBTYPE_FVF_BUILDER_P1_F1(BUILDER,CB,RESULT,F1,SIG,P1,P1fun) \
420 template<typename P1> \
421 inline CB BUILDER(RESULT (*cb)(F1, P1fun), P1 p1) { \
422 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
423 return CB(CASTSIG(SIG,cb), CAST_TO_AW_CL(P1,p1)); \
425 template<typename P1> \
426 inline CB BUILDER(RESULT (*cb)(F1, P1fun), \
427 void (*dealloc)(P1), P1 p1) { \
428 STATIC_ASSERT(CASTABLE_TO_AW_CL(P1)); \
429 return CB(CASTSIG(SIG,cb), CAST_DEALLOCATOR(dealloc), CAST_TO_AW_CL(P1,p1)); \
432 #define CBTYPE_FVF_BUILDER_NP1(BUILDER,CB,RESULT,F1,F2,SIG,SIG01,P1) \
433 inline CB BUILDER(RESULT (*cb)(F1)) { return CB(CASTSIG(SIG01,cb)); } \
434 inline CB BUILDER(RESULT (*cb)(F1,F2)) { return CB(CASTSIG(SIG01,cb)); } \
435 CBTYPE_FVF_BUILDER_P1_F1F2(BUILDER,CB,RESULT,F1,F2,SIG,P1,P1); \
436 CBTYPE_FVF_BUILDER_P1_F1F2(BUILDER,CB,RESULT,F1,F2,SIG,P1,CONST_PARAM_T(P1)); \
437 CBTYPE_FVF_BUILDER_P1_F1(BUILDER,CB,RESULT,F1,SIG,P1,P1); \
438 CBTYPE_FVF_BUILDER_P1_F1(BUILDER,CB,RESULT,F1,SIG,P1,CONST_PARAM_T(P1))
440 #define CBTYPE_FVF_BUILDER_TEMPLATES(BUILDER,CB,RESULT,F1,F2,SIG,SIG01,SIG02) \
441 inline CB BUILDER(RESULT (*cb)()) { return CB((SIG01)cb); } \
442 inline CB BUILDER(RESULT (*cb)(F2)) { return CB((SIG02)cb); } \
443 CBTYPE_FVF_BUILDER_NP1(BUILDER,CB,RESULT,F1,F2,SIG,SIG01,P1); \
444 CBTYPE_FVF_BUILDER_NP1(BUILDER,CB,RESULT,UNFIXED,F2,SIG,SIG01,P1)
449 #define DECLARE_CBTYPE_VV_AND_BUILDERS(CBTYPE,RESULT) \
450 typedef Callback_VV<RESULT> CBTYPE; \
451 CBTYPE_VV_BUILDER_TEMPLATES(make##CBTYPE,CBTYPE,RESULT, \
452 CBTYPE::Signature::FuncType)
454 #define DECLARE_CBTYPE_FVV_AND_BUILDERS(CBTYPE,RESULT,FIXED) \
455 typedef Callback_FVV<RESULT, FIXED> CBTYPE; \
456 CBTYPE_FVV_BUILDER_TEMPLATES(make##CBTYPE,CBTYPE,RESULT,FIXED, \
457 CBTYPE::Signature::FuncType)
459 #define DECLARE_CBTYPE_FFV_AND_BUILDERS(CBTYPE,RESULT,F1,F2) \
460 typedef Callback_FFV<RESULT,F1,F2> CBTYPE; \
461 CBTYPE_FFV_BUILDER_TEMPLATES(make##CBTYPE,CBTYPE,RESULT,F1,F2, \
462 CBTYPE::Signature::FuncType)
464 #define DECLARE_CBTYPE_FVF_AND_BUILDERS(CBTYPE,RESULT,F1,F2) \
465 typedef Callback_FVF<RESULT,F1,F2> CBTYPE; \
466 CBTYPE_FVF_BUILDER_TEMPLATES(make##CBTYPE,CBTYPE,RESULT,F1,F2, \
467 CBTYPE::SigP1::FuncType, \
468 CBTYPE::SigP0F12::FuncType, \
469 CBTYPE::SigP0F2::FuncType)
472 #error cbtypes.h included twice
bool operator==(const Callback_FVV &other) const
bool operator<(const Callback_FFV &other) const
StrictlyTypedCallback< RT, FIXED, AW_CL, AW_CL > Signature
RT operator()(FIXED fixed) const
RT operator()(FP1 p1, FP2 p2, FP3 p3) const
Callback_FVF(SigP0F12 CB)
RT operator()(F1 f1, F2 f2) const
StrictlyTypedCallback(FuncType CB)
StrictlyTypedCallback< RT, F1, F2, AW_CL > Signature
CallbackDataDeallocator dealloc
Callback_FVF(SigP1 CB, UntypedCallbackData::CallbackDataDeallocator dealloc, AW_CL P1)
AW_CL inspect_CD1() const
StrictlyTypedCallback< RT, F2, void, void > SigP0F2
bool operator<(const Callback_FVV &other) const
bool operator<(const Callback_FVF &other) const
AW_CL inspect_CD1() const
bool same_function_as(const Callback_FVF &other) const
CallbackData(P1 p1_, P2 p2_)
StrictlyTypedCallback< RT, AW_CL, AW_CL, AW_CL > Signature
Callback_FVV(Signature CB, UntypedCallbackData::CallbackDataDeallocator dealloc, AW_CL P1, AW_CL P2)
AW_CL inspect_CD2() const
StrictlyTypedCallback< RT, F1, AW_CL, F2 > SigP1
bool operator<(const StrictlyTypedCallback &other) const
RT operator()(F1 f1, F2 f2) const
Function< RT, P1, P2, P3 >::Type FuncType
static AW_CL cast_to_AW_CL(const T &t)
RT operator()(FP1 p1, FP2 p2) const
CallbackData(P1 p1_, P2 p2_, CallbackDataDeallocator dealloc_)
bool operator==(const Callback_FFV &other) const
bool operator<(const CallbackData &other) const
bool same_function_as(const Callback_FVV &other) const
RT operator()(FP1 p1) const
#define INVALID_CB_PARAM_TYPE(TYPE)
CallbackData< AW_CL, AW_CL > UntypedCallbackData
bool operator==(const Callback_VV &other) const
bool operator<(const Callback_VV &other) const
bool equals(const StrictlyTypedCallback &other) const
IfThenElseType< TypeT< T >::IsClassT, typename TypeOp< T >::RefConstT, typename TypeOp< T >::ConstT >::ResultType Type
void(* CallbackDataDeallocator)(P1 p1, P2 p2)
bool operator==(const Callback_FVF &other) const
IfThenElseType< TypeT< T >::IsClassT, typename TypeOp< T >::RefConstT, typename TypeOp< T >::ArgT >::ResultType Type
bool same_function_as(const Callback_VV &other) const
StrictlyTypedCallback< RT, F1, F2, void > SigP0F12
Callback_FVF(SigP1 CB, AW_CL P1)
Callback_FVV(Signature CB, AW_CL P1, AW_CL P2)
Callback_VV(Signature CB, AW_CL P1, AW_CL P2)
bool same_function_as(const Callback_FFV &other) const
Callback_VV(Signature CB, UntypedCallbackData::CallbackDataDeallocator dealloc, AW_CL P1, AW_CL P2)
AW_CL inspect_CD1() const
Callback_FFV(Signature CB, AW_CL P)
AW_CL inspect_CD2() const
static StrictlyTypedCallback make_cb(AW_CL cb_)
TypeOp< T >::ConstT * Type
bool operator==(const StrictlyTypedCallback &other) const
AW_CL inspect_CD2() const
bool operator==(const CallbackData &other) const