Signalv0ImplSerious.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 __SIGNALV0IMPLSERIOUS__
00023 #define __SIGNALV0IMPLSERIOUS__
00024 
00025 #ifndef __SIGNALV0__
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         class Signalv0 
00035                 : public Signal
00036         {
00037         public:
00038                 typedef CBL::Functor0     tCallbackType;
00039         public:
00040                 virtual ~Signalv0()
00041                 {
00042                         mSuper.DestroyConnections();
00043                 }
00044   
00045                 void Connect( Slotv0& slot )
00046                 {
00047                         Connection c ( AssignConnection(), this );
00048     
00049                         mSuper.AddCallback( c.GetID(), &slot, slot.GetMethod() );
00050     
00051                         slot.Bind(c);
00052                 }
00053   
00054                 void Emit()
00055                 {
00056                         if ( mSuper.HasNoCallbacks() )
00057                                 return;
00058     
00059                         tSuperType::tCallList calls = mSuper.GetCalls();
00060                         tSuperType::tCallIterator i = calls.begin();
00061                         tSuperType::tCallIterator end = calls.end();
00062     
00063                         while( i != end )
00064                         {
00065                                 (*(*i))();
00066                                 i++;
00067                         }
00068                 }
00069   
00070                 void FreeConnection( Connection* pConnection )
00071                 {
00072                         mSuper.RemoveCall( pConnection->GetID() );
00073                         FreeConnectionId( pConnection->GetID() );
00074                 }
00075   
00076         private:
00077                 typedef Signalv0                            tSignalType;
00078                 typedef ConnectionHandler<tSignalType >     tSuperType;
00079   
00080                 tSuperType  mSuper;
00081         };
00082 
00083 }
00084 
00085 #endif // Signalv0ImplSerious.hxx
00086 
Generated by  doxygen 1.6.3