CLAM-Development  1.4.0
Signalv4ImplSerious.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef __SIGNALV4IMPLSERIOUS__
23 #define __SIGNALV4IMPLSERIOUS__
24 
25 #ifndef __SIGNALV4__
26 #error "This is an internal implementation header. You are not allowed to include it directly!"
27 #endif
28 
29 #include "ConnectionHandler.hxx"
30 
31 namespace SigSlot
32 {
33 
34 template < typename ParmType1, typename ParmType2, typename ParmType3, typename ParmType4 >
35  class Signalv4 : public Signal
36 {
37 public:
38  typedef typename CBL::Functor4<ParmType1,ParmType2, ParmType3,ParmType4> tCallbackType;
39 
40 public:
41 
42  virtual ~Signalv4()
43  {
44  mSuper.DestroyConnections();
45  }
46 
48  {
49  Connection c( AssignConnection(), this );
50 
51  mSuper.AddCallback( c.GetID(), &slot, slot.GetMethod() );
52 
53  slot.Bind(c);
54  }
55 
56  void Emit( ParmType1 parm1, ParmType2 parm2, ParmType3 parm3, ParmType4 parm4 )
57  {
58  if ( mSuper.HasNoCallbacks() )
59  return;
60 
61  typename tSuperType::tCallList calls = mSuper.GetCalls();
62  typename tSuperType::tCallIterator i = calls.begin();
63  typename tSuperType::tCallIterator end = calls.end();
64 
65  while ( i != end )
66  {
67  (*(*i))( parm1, parm2, parm3, parm4 );
68  i++;
69  }
70 
71  }
72 
73  void FreeConnection( Connection* pConnection )
74  {
75  mSuper.RemoveCall( pConnection->GetID() );
76  FreeConnectionId( pConnection->GetID() );
77  }
78 private:
80  typedef ConnectionHandler<tSignalType > tSuperType;
81 
82  tSuperType mSuper;
83 };
84 
85 }
86 
87 
88 #endif // Signalv2ImplSerious.hxx
89