ProcessingComposite.cxx

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 #include "Assert.hxx"
00023 #include "ProcessingComposite.hxx"
00024 
00025 namespace CLAM {
00026 
00027         bool ProcessingComposite::ConcreteStart()
00028         {
00029                 iterator obj;
00030                 for (obj=composite_begin(); obj!=composite_end(); obj++)
00031                 {
00032                         try {
00033                                 (*obj)->Start();
00034                         }
00035                         catch (Err &e)
00036                         {
00037                                 iterator obj2;
00038                                 for (obj2 = composite_begin(); obj2 != obj; obj2++)
00039                                         (*obj2)->Stop();
00040                                 throw e;
00041                         }
00042                         if (!(*obj)->IsRunning())
00043                         {
00044                                 iterator obj2;
00045                                 for (obj2 = composite_begin(); obj2 != obj; obj2++)
00046                                         (*obj2)->Stop();
00047                                 throw(ErrProcessingObj("ConcreteStart(): Child failed to start",this));
00048                         }
00049                 }
00050                 return true;
00051         }
00052 
00053         bool ProcessingComposite::ConcreteStop()
00054         {
00055                 iterator obj;
00056                 for (obj=composite_begin(); obj!=composite_end(); obj++)
00057                         (*obj)->Stop();
00058                 return true;
00059         }
00060 
00061         void ProcessingComposite::Remove(Processing& obj)
00062         {
00063                 iterator it;
00064                 for (it=composite_begin(); it!=composite_end(); it++)
00065                         if ( (*it) == &obj)
00066                                 break;
00067                 if (it == composite_end())
00068                         return; // Not found!
00069                 mObjects.remove(&obj);
00070         }
00071 
00072         void ProcessingComposite::Insert(Processing& obj) throw(ErrProcessingObj)
00073         {
00074                 iterator it;
00075                 for (it=mObjects.begin(); it!=mObjects.end(); it++)
00076                         if((*it)==&obj) return;                         
00077                 mObjects.push_back(&obj);
00078         }
00079 }
00080 
Generated by  doxygen 1.6.3