#if !defined( INCLUDED_ISIGNAL_H ) #define INCLUDED_ISIGNAL_H #include "generic/callback.h" #include "signal/signalfwd.h" class SignalHandlerResult { bool value; public: explicit SignalHandlerResult( bool value ) : value( value ){ } bool operator==( SignalHandlerResult other ) const { return value == other.value; } bool operator!=( SignalHandlerResult other ) const { return !operator==( other ); } }; const SignalHandlerResult SIGNAL_CONTINUE_EMISSION = SignalHandlerResult( false ); const SignalHandlerResult SIGNAL_STOP_EMISSION = SignalHandlerResult( true ); template class SignalHandlerCallerN; template class SignalHandlerCallerN { public: using func = SignalHandlerResult(Ts ...); static SignalHandlerResult call(Ts... args) { Caller::call(args ...); return SIGNAL_CONTINUE_EMISSION; } }; template using SignalHandlerCaller = SignalHandlerCallerN >; template using SignalHandlerCaller1 = SignalHandlerCaller; template using SignalHandlerCaller2 = SignalHandlerCaller; template using SignalHandlerCaller3 = SignalHandlerCaller; template using SignalHandlerCaller4 = SignalHandlerCaller; template class TypeEqual { public: using type = False; }; template class TypeEqual { public: using type = True; }; template class Wrapper> class SignalHandlerN : public CB { public: template SignalHandlerN(const BindFirstOpaque &caller) : CB(BindFirstOpaque, get_result_type >::type>(caller.getBound())) { } }; class SignalHandler : public SignalHandlerN, SignalHandlerCaller1> { using SignalHandlerN, SignalHandlerCaller1>::SignalHandlerN; }; template inline SignalHandler makeSignalHandler( const BindFirstOpaque& caller ){ return SignalHandler( caller ); } template inline SignalHandler makeSignalHandler(const Caller &caller, get_argument callee) { return SignalHandler( BindFirstOpaque( callee ) ); } template class SignalHandler1 : public SignalHandlerN, SignalHandlerCaller2> { using SignalHandlerN, SignalHandlerCaller2>::SignalHandlerN; }; template inline SignalHandler1 > makeSignalHandler1(const BindFirstOpaque &caller) { return SignalHandler1 >(caller); } template inline SignalHandler1 > makeSignalHandler1(const Caller &caller, get_argument callee) { return SignalHandler1 >(BindFirstOpaque(callee)); } template class SignalHandler2 : public SignalHandlerN, SignalHandlerCaller3> { using SignalHandlerN, SignalHandlerCaller3>::SignalHandlerN; }; template inline SignalHandler2< get_argument, get_argument > makeSignalHandler2(const BindFirstOpaque &caller) { return SignalHandler2< get_argument, get_argument >( caller ); } template inline SignalHandler2< get_argument, get_argument > makeSignalHandler2(const Caller &caller, get_argument callee) { return SignalHandler2< get_argument, get_argument >(BindFirstOpaque(callee)); } template class SignalHandler3 : public SignalHandlerN, SignalHandlerCaller4> { using SignalHandlerN, SignalHandlerCaller4>::SignalHandlerN; }; template inline SignalHandler3< get_argument, get_argument, get_argument > makeSignalHandler3(const BindFirstOpaque &caller) { return SignalHandler3< get_argument, get_argument, get_argument >( caller ); } template inline SignalHandler3< get_argument, get_argument, get_argument > makeSignalHandler3(const Caller &caller, get_argument callee) { return SignalHandler3< get_argument, get_argument, get_argument >(BindFirstOpaque(callee)); } #endif