Signalv4ImplSerious.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef __SIGNALV4IMPLSERIOUS__
00023 #define __SIGNALV4IMPLSERIOUS__
00024 
00025 #ifndef __SIGNALV4__
00026 #error "This is an internal implementation header. You are not allowed to include it directly!"
00027 #endif
00028 
00029 #include "ConnectionHandler.hxx"
00030 
00031 namespace SigSlot
00032 {
00033 
00034 template < typename ParmType1, typename ParmType2, typename ParmType3, typename ParmType4 >
00035         class Signalv4 : public Signal
00036 {
00037 public:
00038         typedef typename CBL::Functor4<ParmType1,ParmType2, ParmType3,ParmType4>              tCallbackType;
00039 
00040 public:
00041         
00042         virtual ~Signalv4()
00043         {
00044                 mSuper.DestroyConnections();
00045         }
00046 
00047         void Connect( Slotv4<ParmType1, ParmType2, ParmType3, ParmType4>& slot )
00048         {
00049                 Connection c( AssignConnection(), this );
00050 
00051                 mSuper.AddCallback( c.GetID(), &slot, slot.GetMethod() );
00052 
00053                 slot.Bind(c);
00054         }
00055         
00056         void Emit( ParmType1 parm1, ParmType2 parm2, ParmType3 parm3, ParmType4 parm4 )
00057         {
00058                 if ( mSuper.HasNoCallbacks() )
00059                         return;
00060                 
00061                 typename tSuperType::tCallList calls = mSuper.GetCalls();
00062                 typename tSuperType::tCallIterator i = calls.begin();
00063                 typename tSuperType::tCallIterator end = calls.end();
00064 
00065                 while ( i != end )
00066                         {
00067                                 (*(*i))( parm1, parm2, parm3, parm4 );
00068                                 i++;
00069                         }
00070                 
00071         }
00072 
00073         void FreeConnection( Connection* pConnection )
00074         {
00075                 mSuper.RemoveCall( pConnection->GetID() );
00076                 FreeConnectionId( pConnection->GetID() );
00077         }
00078 private:
00079         typedef Signalv4<ParmType1,ParmType2,ParmType3, ParmType4> tSignalType;
00080         typedef ConnectionHandler<tSignalType >     tSuperType;
00081 
00082         tSuperType  mSuper;
00083 };
00084 
00085 }
00086 
00087 
00088 #endif // Signalv2ImplSerious.hxx
00089 
Generated by  doxygen 1.6.3