CLAM-Development  1.4.0
ProcessingComposite.cxx
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 #include "Assert.hxx"
23 #include "ProcessingComposite.hxx"
24 
25 namespace CLAM {
26 
28  {
29  iterator obj;
30  for (obj=composite_begin(); obj!=composite_end(); obj++)
31  {
32  try {
33  (*obj)->Start();
34  }
35  catch (Err &e)
36  {
37  iterator obj2;
38  for (obj2 = composite_begin(); obj2 != obj; obj2++)
39  (*obj2)->Stop();
40  throw e;
41  }
42  if (!(*obj)->IsRunning())
43  {
44  iterator obj2;
45  for (obj2 = composite_begin(); obj2 != obj; obj2++)
46  (*obj2)->Stop();
47  throw(ErrProcessingObj("ConcreteStart(): Child failed to start",this));
48  }
49  }
50  return true;
51  }
52 
54  {
55  iterator obj;
56  for (obj=composite_begin(); obj!=composite_end(); obj++)
57  (*obj)->Stop();
58  return true;
59  }
60 
62  {
63  iterator it;
64  for (it=composite_begin(); it!=composite_end(); it++)
65  if ( (*it) == &obj)
66  break;
67  if (it == composite_end())
68  return; // Not found!
69  mObjects.remove(&obj);
70  }
71 
73  {
74  iterator it;
75  for (it=mObjects.begin(); it!=mObjects.end(); it++)
76  if((*it)==&obj) return;
77  mObjects.push_back(&obj);
78  }
79 }
80