C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/src/ProcessManager.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #include "ProcessManager.h"
00022 
00023 namespace GameEngine {
00024         
00025         void ProcessManager::attach(boost::shared_ptr<Process> process)
00026         {
00027                 mProcessList.push_back(process);
00028                 process->setAttached(true);
00029         }
00030 
00031 
00032         void ProcessManager::detach(boost::shared_ptr<Process> process)
00033         {
00034                 mProcessList.remove(process);
00035                 process->setAttached(false);
00036         }
00037         
00038 
00039         void ProcessManager::updateProcesses(const double& dt)
00040         {
00041                 ProcessList::iterator it = mProcessList.begin();
00042 
00043                 boost::shared_ptr<Process> next;
00044 
00045                 while( it != mProcessList.end() ){
00046                         boost::shared_ptr<Process> process = boost::shared_ptr<Process>(*it);
00047                         it++;
00048 
00049                         if( process->isDead() ){
00050                                 next = process->getNext();
00051 
00052                                 if(next){
00053                                         process->setNext( boost::shared_ptr<Process>( (Process*) NULL) );
00054                                         attach(next);
00055                                 }
00056 
00057                                 detach(process);
00058                         }
00059                         else if( process->isInitialised() && process->isActive() && !process->isPaused() ){
00060                                 process->update(dt);
00061                         }
00062                 }
00063         }
00064 
00065         void ProcessManager::deleteProcessList()
00066         {
00067                 for(ProcessList::iterator it = mProcessList.begin(); it != mProcessList.end(); ){
00068                         detach(*(it++));
00069                 }
00070         }
00071 
00072         bool ProcessManager::hasProcesses() const
00073         {
00074                 return !mProcessList.empty();
00075         }
00076 
00077 }

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2