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 "OMKFrameScheduler.h" 00019 00020 #include "OMKReferenceObjectHandle.h" 00021 #include "OMKSimulatedObject.h" 00022 #include "OMKDoubleList.h" 00023 #include "OMKDoubleListElement.h" 00024 #include "OMKTracer.h" 00025 00026 using namespace OMK ; 00027 00028 FrameScheduler::FrameScheduler(unsigned int numberOfSteps) : 00029 Scheduler(numberOfSteps) 00030 { 00031 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::FrameScheduler ( " << numberOfSteps << " )" ); 00032 00033 Frames = new DoubleList *[_numberOfSteps]; 00034 for(unsigned int i = 0 ; i < _numberOfSteps ; i++) 00035 { 00036 Frames[i]=new DoubleList(); 00037 } 00038 } 00039 00040 FrameScheduler::~FrameScheduler () 00041 { 00042 if (Frames!=NULL) 00043 { 00044 for(unsigned int i = 0 ; i <_numberOfSteps ; i ++) 00045 { 00046 if(Frames[ i ]!=NULL) delete Frames[i]; 00047 } 00048 delete [] Frames; 00049 } 00050 } 00051 00052 00053 void FrameScheduler::addToScheduable (ReferenceObjectHandle * ref, unsigned int when) 00054 { 00055 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::addToScheduable( \"" << ref->getSimulatedObject().getName() << "\", "<<when<<" )" ); 00056 00057 Frames[when]->insert(ref) ; 00058 } 00059 00060 void FrameScheduler::removeFromScheduable (ReferenceObjectHandle * ref) 00061 { 00062 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::removeFromScheduable ( \"" << ref->getSimulatedObject().getName() << "\" )" ) ; 00063 00064 for (unsigned int i = 0 ; i < _numberOfSteps ; i++ ) 00065 { 00066 Frames[i] -> remove ( ref ) ; 00067 } 00068 } 00069 00070 void FrameScheduler::schedule(ReferenceObjectHandle * ref) 00071 { 00072 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::schedule( \"" << ref->getSimulatedObject().getName() << "\" )" ) ; 00073 00074 for (unsigned int i = 0 ; i < _numberOfSteps ; i++ ) 00075 { 00076 Frames[i] -> activate ( ref ) ; 00077 } 00078 } 00079 00080 void FrameScheduler::unschedule(ReferenceObjectHandle * ref) 00081 { 00082 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::unschedule \"" << ref->getSimulatedObject().getName() << "\" )" ) ; 00083 00084 for (unsigned int i = 0 ; i < _numberOfSteps ; i++ ) 00085 { 00086 Frames[i] -> suspend ( ref ) ; 00087 } 00088 } 00089 00090 00091 void FrameScheduler::runStep (unsigned int which) 00092 { 00093 OMTRACEID( OMK_DEBUG_OMK_EXEC, "FrameScheduler::runStep: Running step " << which ) ; 00094 DoubleListElement * pListe ; 00095 for( pListe = Frames [which]->begin () ; 00096 pListe != NULL ; 00097 pListe = Frames[which]->next (pListe)) 00098 { 00099 OMTRACEID( OMK_DEBUG_OMK_EXEC, "Calling compute of "<< OMK::debugMsg( &pListe->listeElem->getSimulatedObject() ) ) ; 00100 (*pListe).listeElem->compute () ; 00101 OMTRACEID( OMK_DEBUG_OMK_EXEC, "Compute of "<< OMK::debugMsg( &pListe->listeElem->getSimulatedObject() ) << " done" ) ; 00102 } 00103 00104 } 00105
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |