From 54230c9a4474baf4f1c56773992212093e222349 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 29 Apr 2011 10:32:21 +0200 Subject: 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 | 94 +++++++++++++++++------------------------------------- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh index 3c17d1a..79d001f 100644 --- a/src/FbTk/Signal.hh +++ b/src/FbTk/Signal.hh @@ -101,52 +101,34 @@ private: Trackers m_trackers; ///< all instances that tracks this signal. }; -/// Signal with no argument -template -class Signal0: public SignalHolder { -public: - typedef Slot0 SlotType; - - ~Signal0() { } +struct EmptyArg {}; - void emit() { - for ( Iterator it = begin(); it != end(); ++it ) { - static_cast(*it)(); - } - } +} // namespace SigImpl - SlotID connect(const SlotType& slot) { - return SignalHolder::connect(slot); - } -}; -/// Signal with one argument -template -class Signal1: public SignalHolder { +/// Specialization for three arguments. +template +class Signal: public SigImpl::SignalHolder { public: - typedef Slot1 SlotType; + typedef SigImpl::Slot3 SlotType; - ~Signal1() { } - - void emit(Arg1 arg) { + void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { for ( Iterator it = begin(); it != end(); ++it ) { - static_cast(*it)(arg); + static_cast(*it)(arg1, arg2, arg3); } } 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 > { +/// Specialization for no arguments. +template +class Signal: public SigImpl::SignalHolder { public: -}; + typedef SigImpl::Slot0 SlotType; -/// 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: -}; + void emit() { + for ( Iterator it = begin(); it != end(); ++it ) { + static_cast(*it)(); + } + } -/// Specialization for no argument. -template -class Signal: public SigImpl::Signal0< ReturnType > { -public: + SlotID connect(const SlotType& slot) { + return SignalHolder::connect(slot); + } }; /** -- cgit v0.11.2