From 54230c9a4474baf4f1c56773992212093e222349 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 29 Apr 2011 10:32:21 +0200 Subject: [PATCH] Simplify FbTk::Signal template classes a bit basically, i just got rid of Signal[0-3] classes and moved their contents to the appropriate specialization of FbTk::Signal also, this fixes the no matching function for call to 'MemFunIgnoreArgs(FbTk::Signal&, void (FbTk::SigImpl::Signal0::*)())' error i had in the following commit. --- src/FbTk/Signal.hh | 102 +++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 68 deletions(-) diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh index 3c17d1a7..79d001f1 100644 --- a/src/FbTk/Signal.hh +++ b/src/FbTk/Signal.hh @@ -101,17 +101,21 @@ private: Trackers m_trackers; ///< all instances that tracks this signal. }; -/// Signal with no argument -template -class Signal0: public SignalHolder { +struct EmptyArg {}; + +} // namespace SigImpl + + +/// Specialization for three arguments. +template +class Signal: public SigImpl::SignalHolder { public: - typedef Slot0 SlotType; + typedef SigImpl::Slot3 SlotType; - ~Signal0() { } - - void emit() { + void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { for ( Iterator it = begin(); it != end(); ++it ) { - static_cast(*it)(); + static_cast(*it)(arg1, arg2, arg3); } } @@ -120,33 +124,11 @@ public: } }; -/// Signal with one argument -template -class Signal1: public SignalHolder { -public: - typedef Slot1 SlotType; - - ~Signal1() { } - - void emit(Arg1 arg) { - for ( Iterator it = begin(); it != end(); ++it ) { - static_cast(*it)(arg); - } - } - - SlotID connect(const SlotType& slot) { - return SignalHolder::connect(slot); - } - -}; - -/// Signal with two arguments +/// Specialization for two arguments. template -class Signal2: public SignalHolder { +class Signal: public SigImpl::SignalHolder { public: - typedef Slot2 SlotType; - - ~Signal2() { } + typedef SigImpl::Slot2 SlotType; void emit(Arg1 arg1, Arg2 arg2) { for ( Iterator it = begin(); it != end(); ++it ) { @@ -159,54 +141,38 @@ public: } }; -/// Signal with three arguments -template -class Signal3: public SignalHolder { +/// Specialization for one argument. +template +class Signal: public SigImpl::SignalHolder { public: - typedef Slot3 SlotType; + typedef SigImpl::Slot1 SlotType; - ~Signal3() { } - - void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { + void emit(Arg1 arg) { for ( Iterator it = begin(); it != end(); ++it ) { - static_cast(*it)(arg1, arg2, arg3); + static_cast(*it)(arg); } } SlotID connect(const SlotType& slot) { return SignalHolder::connect(slot); } - }; -struct EmptyArg {}; - -} // namespace SigImpl - - -/// Specialization for three arguments. -template -class Signal: public SigImpl::Signal3< ReturnType, Arg1, Arg2, Arg3 > { -public: -}; - -/// Specialization for two arguments. -template -class Signal: public SigImpl::Signal2< ReturnType, Arg1, Arg2 > { -public: -}; - -/// Specialization for one argument. -template -class Signal: public SigImpl::Signal1< ReturnType, Arg1 > { -public: -}; - -/// Specialization for no argument. +/// Specialization for no arguments. template -class Signal: public SigImpl::Signal0< ReturnType > { +class Signal: public SigImpl::SignalHolder { public: + typedef SigImpl::Slot0 SlotType; + + void emit() { + for ( Iterator it = begin(); it != end(); ++it ) { + static_cast(*it)(); + } + } + + SlotID connect(const SlotType& slot) { + return SignalHolder::connect(slot); + } }; /**