Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnFrameScheduler.cxx

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *  
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license
00016  *
00017  */
00018 #include "PsnFrameScheduler.h"
00019 
00020 #include "PsnReferenceObjectHandle.h"
00021 #include "PsSimulatedObject.h"
00022 #include "PsnDoubleList.h"
00023 
00024 
00025 PsnFrameScheduler::PsnFrameScheduler(unsigned int numberOfSteps) :
00026    PsnScheduler(numberOfSteps)
00027 {
00028    Frames = new PsnDoubleList *[_numberOfSteps];
00029    for(int i = 0 ; i < _numberOfSteps ; i++) {
00030 
00031       Frames[i]=new PsnDoubleList();
00032 
00033    }  
00034 }
00035 
00036 PsnFrameScheduler::~PsnFrameScheduler () {
00037    if (Frames!=NULL) {
00038       for(int i = 0 ; i <_numberOfSteps ; i ++) {
00039          if(Frames[ i ]!=NULL) delete Frames[i];
00040       }
00041       delete [] Frames;
00042    }
00043 }
00044 
00045 
00046 void PsnFrameScheduler::addToScheduable (PsnReferenceObjectHandle * ref, unsigned int when) {
00047 
00048    Frames[when]->insert(ref) ;
00049    
00050 }
00051 
00052 void PsnFrameScheduler::removeFromScheduable (PsnReferenceObjectHandle * ref) {
00053 
00054    for (int i = 0 ; i < _numberOfSteps ; i++ ) {
00055 
00056       Frames[i] -> remove ( ref ) ;
00057    }
00058 }
00059 
00060 void PsnFrameScheduler::schedule(PsnReferenceObjectHandle * ref) {
00061 
00062    for (int i = 0 ; i < _numberOfSteps ; i++ ) {
00063 
00064       Frames[i] -> activate ( ref ) ;
00065 
00066    }
00067 
00068 
00069 }
00070 
00071 void PsnFrameScheduler::unschedule(PsnReferenceObjectHandle * ref) {
00072 
00073    for (int i = 0 ; i < _numberOfSteps ; i++ ) {
00074 
00075       Frames[i] -> suspend ( ref ) ;
00076 
00077    }
00078 
00079 
00080 }
00081 
00082 
00083 void PsnFrameScheduler::runStep (unsigned int which) 
00084 {
00085 #if defined (_DEBUGSCHEDULER) || defined (_DEBUGEXEC)
00086    cerr<<"PsnFrameScheduler::runStep: Running step "<<which<<endl;
00087 #endif
00088    PsnDoubleListElement * pListe ;
00089    for (pListe = Frames [which]->begin () ;
00090         pListe != NULL ; 
00091         pListe = Frames[which]->next (pListe)) {
00092 #if defined (_DEBUGSCHEDULER) || defined (_DEBUGEXEC)
00093       cerr<<"Calling compute of object "<<(*pListe).listeElem->getSimulatedObject ().getName()<<" ";
00094 #endif
00095       (*pListe).listeElem->compute () ;
00096 #if defined (_DEBUGSCHEDULER) || defined (_DEBUGEXEC)
00097       cerr<<"done "<<endl;
00098 #endif
00099    }
00100 
00101 }
00102 

logo OpenMask

Documentation generated on Mon Nov 25 15:25:00 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001