#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 SignalHandlerCaller1 { public: typedef typename Caller::first_argument_type first_argument_type; typedef SignalHandlerResult result_type; static result_type call( first_argument_type a1 ){ Caller::call( a1 ); return SIGNAL_CONTINUE_EMISSION; } }; template class SignalHandlerCaller2 { public: typedef typename Caller::first_argument_type first_argument_type; typedef typename Caller::second_argument_type second_argument_type; typedef SignalHandlerResult result_type; static result_type call( first_argument_type a1, second_argument_type a2 ){ Caller::call( a1, a2 ); return SIGNAL_CONTINUE_EMISSION; } }; template class SignalHandlerCaller3 { public: typedef typename Caller::first_argument_type first_argument_type; typedef typename Caller::second_argument_type second_argument_type; typedef typename Caller::third_argument_type third_argument_type; typedef SignalHandlerResult result_type; static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3 ){ Caller::call( a1, a2, a3 ); return SIGNAL_CONTINUE_EMISSION; } }; template class SignalHandlerCaller4 { public: typedef typename Caller::first_argument_type first_argument_type; typedef typename Caller::second_argument_type second_argument_type; typedef typename Caller::third_argument_type third_argument_type; typedef typename Caller::fourth_argument_type fourth_argument_type; typedef SignalHandlerResult result_type; static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){ Caller::call( a1, a2, a3, a4 ); return SIGNAL_CONTINUE_EMISSION; } }; class SignalHandler : public Callback0 { public: template SignalHandler( const BindFirstOpaque& caller ) : Callback0( BindFirstOpaque, typename Caller::result_type >::type>( caller.getBound() ) ){ } }; template inline SignalHandler makeSignalHandler( const BindFirstOpaque& caller ){ return SignalHandler( caller ); } template inline SignalHandler makeSignalHandler( const Caller& caller, typename Caller::first_argument_type callee ){ return SignalHandler( BindFirstOpaque( callee ) ); } template class SignalHandler1 : public Callback1 { public: template SignalHandler1( const BindFirstOpaque1& caller ) : Callback1( BindFirstOpaque1, typename Caller::result_type >::type>( caller.getBound() ) ){ } }; template inline SignalHandler1 makeSignalHandler1( const BindFirstOpaque1& caller ){ return SignalHandler1( caller ); } template inline SignalHandler1 makeSignalHandler1( const Caller& caller, typename Caller::first_argument_type callee ){ return SignalHandler1( BindFirstOpaque1( callee ) ); } template class SignalHandler2 : public Callback2 { public: template SignalHandler2( const BindFirstOpaque2& caller ) : Callback2( BindFirstOpaque2, typename Caller::result_type >::type>( caller.getBound() ) ){ } }; template inline SignalHandler2< typename Caller::second_argument_type, typename Caller::third_argument_type > makeSignalHandler2( const BindFirstOpaque2& caller ){ return SignalHandler2< typename Caller::second_argument_type, typename Caller::third_argument_type >( caller ); } template inline SignalHandler2< typename Caller::second_argument_type, typename Caller::third_argument_type > makeSignalHandler2( const Caller& caller, typename Caller::first_argument_type callee ){ return SignalHandler2< typename Caller::second_argument_type, typename Caller::third_argument_type >( BindFirstOpaque2( callee ) ); } template class SignalHandler3 : public Callback3 { public: template SignalHandler3( const BindFirstOpaque3& caller ) : Callback3( BindFirstOpaque3, typename Caller::result_type >::type>( caller.getBound() ) ){ } }; template inline SignalHandler3< typename Caller::second_argument_type, typename Caller::third_argument_type, typename Caller::fourth_argument_type > makeSignalHandler3( const BindFirstOpaque3& caller ){ return SignalHandler3< typename Caller::second_argument_type, typename Caller::third_argument_type, typename Caller::fourth_argument_type >( caller ); } template inline SignalHandler3< typename Caller::second_argument_type, typename Caller::third_argument_type, typename Caller::fourth_argument_type > makeSignalHandler3( const Caller& caller, typename Caller::first_argument_type callee ){ return SignalHandler3< typename Caller::second_argument_type, typename Caller::third_argument_type, typename Caller::fourth_argument_type >( BindFirstOpaque3( callee ) ); } #endif