CLAM-Development  1.4.0
Signalv0ImplSerious.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 __SIGNALV0IMPLSERIOUS__
23 #define __SIGNALV0IMPLSERIOUS__
24 
25 #ifndef __SIGNALV0__
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  class Signalv0
35  : public Signal
36  {
37  public:
38  typedef CBL::Functor0 tCallbackType;
39  public:
40  virtual ~Signalv0()
41  {
42  mSuper.DestroyConnections();
43  }
44 
45  void Connect( Slotv0& slot )
46  {
47  Connection c ( AssignConnection(), this );
48 
49  mSuper.AddCallback( c.GetID(), &slot, slot.GetMethod() );
50 
51  slot.Bind(c);
52  }
53 
54  void Emit()
55  {
56  if ( mSuper.HasNoCallbacks() )
57  return;
58 
59  tSuperType::tCallList calls = mSuper.GetCalls();
60  tSuperType::tCallIterator i = calls.begin();
61  tSuperType::tCallIterator end = calls.end();
62 
63  while( i != end )
64  {
65  (*(*i))();
66  i++;
67  }
68  }
69 
70  void FreeConnection( Connection* pConnection )
71  {
72  mSuper.RemoveCall( pConnection->GetID() );
73  FreeConnectionId( pConnection->GetID() );
74  }
75 
76  private:
77  typedef Signalv0 tSignalType;
78  typedef ConnectionHandler<tSignalType > tSuperType;
79 
80  tSuperType mSuper;
81  };
82 
83 }
84 
85 #endif // Signalv0ImplSerious.hxx
86