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

PsSpecialisedMomeOuput.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 <PsOutput.h>
00019 #include <PsMomeOutput.h>
00020 
00021 #include <PsMomeController.h>
00022 #include <PsnMomeMemoryManager.h>
00023 #include <PsnOutputSharedData.h>
00024 
00025 
00026 void PsMomeOutput<PsList<PsInt> >::extract(istream & in) {
00027    //on s'en fiche de in, puisqu'on a déjà les infos sous la bonne forme !
00029    if(_myDataMemoryManager->localAddressToGlobal(_mesDonnees->usedOutputDataOffset)!=NULL){
00030       
00031    }
00032    if(_myDataMemoryManager->localAddressToGlobal(_mesDonnees->historyFifoOffsetsOutputAsc)!=NULL){
00033 
00034    }
00035    if(_myDataMemoryManager->localAddressToGlobal(_mesDonnees->principalAliasDataOffset)!=NULL){
00036 
00037    }
00038    if(_mesDonnees->_validity!=_validity){
00039       setValidity(_mesDonnees->_validity);
00040    }
00041       
00042 }
00043 
00044 //-----------------------------------------------------------------
00045 
00046 inline PsMomeOutput<PsList<PsInt> >::PsMomeOutput (const PsName & nom,
00047                                          PsSimulatedObject *prop,
00048                                          const int tailleFile,
00049                                          PsPolatorNT * interpolateur)
00050    : PsOutput<PsList<PsInt> > (nom,prop,tailleFile,interpolateur), _monNom(nom)
00051 {
00052    //on détruit la file classique, et on en crée (ou en en récupère) une adaptée, et on recole les morceaux
00053    delete _history;
00054 
00055    //cerr<<"PsMomeOutput<Type>::PsMomeOutput "<<endl;
00056 
00057    _monControleur=dynamic_cast<PsMomeController *>(owner->Controleur());
00058 
00059    if (_monControleur!=NULL) {
00060 
00061       _myDataMemoryManager=PsMomeController::outputDataSharedMemoryManager;
00062 
00063       _mesDonnees = _monControleur->creerDonneesOutput(prop->Nom(),nom);
00064 
00065       _myDataMemoryManager->lock();
00066 
00067       _myDataMemoryManager->syncOfLock((void *)_mesDonnees,sizeof(PsnOutputSharedData));
00068 
00069       if (_myDataMemoryManager->invalidOffset(_mesDonnees->historyFifoOffset)) {
00070 
00071          int tailleReel = tailleFile + _polator->getNumberOfNeededValuesForMaxPrecisionPolation();
00072 
00073          CurrentAllocator titi(prop->Nom(),CurrentAllocator::Write);
00074 
00075          _history = new(_myDataMemoryManager) PsnMomeFifo < PsList<PsInt>  > ( tailleReel , _myDataMemoryManager ) ;
00076 
00077          _mesDonnees->historyFifoOffset=_myDataMemoryManager->globalAddressToLocal( _history );
00078          
00079       }
00080       else {
00081 
00082          _history = (PsnMomeFifo <PsList<PsInt>  > *)_myDataMemoryManager->localAddressToGlobal(_mesDonnees->historyFifoOffset);
00083 
00084       }
00085 
00086       _myDataMemoryManager->unlock();
00087       
00088    }
00089    else {
00090       cerr<<"PsMomeOutput<"<<typeid(PsList<PsInt> ).name()<<">::constructeur"
00091           <<"Controleur de type Mome attendu, mais de type "<<typeid(prop->Controleur()).name()<<endl;
00092       PsController::error("");
00093    }
00094 
00095    _polator->setFifo(_history);
00096    //cerr<<"PsMomeOutput<Type>::PsMomeOutput fin de creation de la MomeOutput"<<endl;
00097 }
00098 
00099 //-----------------------------------------------------------------
00100 
00101 inline PsMomeOutput<PsList<PsInt> >::~PsMomeOutput (void)
00102 {
00103    _monControleur->invalidateOutput(owner->Nom(),_monNom);
00104    //cerr<<"Fin destructeur de PsMomeOutput <"<<typeid(Type).name()<<">"<<endl;
00105 }
00106 
00107 //-----------------------------------------------------------------
00108 void PsMomeOutput<PsList<PsInt> >::setValidity(bool b) {
00109    PsOutput<PsList<PsInt> >::setValidity(b);
00110    _mesDonnees->_validity=b;
00111 }
00112 
00113 //-----------------------------------------------------------------
00114 
00115 void PsMomeOutput<PsList<PsInt> >::setOutputAscendant(PsOutput<PsList<PsInt> > * output)  {
00116    PsOutput<PsList<PsInt> >::setOutputDescendant(output);
00117    PsMomeOutput<PsList<PsInt> > * laOutput  = dynamic_cast<PsMomeOutput<PsList<PsInt> > *>(output);
00118    _mesDonnees->historyFifoOffsetsOutputAsc=_myDataMemoryManager->globalAddressToLocal(laOutput->_mesDonnees);
00119 }
00120 
00121 //-----------------------------------------------------------------
00122 
00123 void PsMomeOutput<PsList<PsInt> >::setOutputDescendant(PsOutput<PsList<PsInt> > * output)  {
00124    PsOutput<PsList<PsInt> >::setOutputDescendant(output);
00125    PsMomeOutput<PsList<PsInt> > * laOutput  = dynamic_cast<PsMomeOutput<PsList<PsInt> > *>(output);
00126    _mesDonnees->principalAliasDataOffset=_myDataMemoryManager->globalAddressToLocal(laOutput->_mesDonnees);
00127 }
00128 
00129 //-----------------------------------------------------------------
00130 
00131 void PsMomeOutput<PsList<PsInt> >::setUsedOutput(PsOutput<PsList<PsInt> > * output)  {
00132    PsOutput<PsList<PsInt> >::setUsedOutput(output);
00133    PsMomeOutput<PsList<PsInt> > * laOutput  = dynamic_cast<PsMomeOutput<PsList<PsInt> > *>(output);
00134    _mesDonnees->usedOutputDataOffset=_myDataMemoryManager->globalAddressToLocal(laOutput->_mesDonnees);
00135 }
00136 
00137 const PsList<PsInt>  & PsMomeOutput<PsList<PsInt> >::get(int & validiteRes,
00138                                      const int niveauInterpol,
00139                                      const PsDate & deltaT) const
00140 {
00141    try {
00142       return PsOutput<PsList<PsInt> >::get(validiteRes,niveauInterpol,deltaT);
00143    }
00144    catch (PsUnInitialisedOutputException & s) {
00145       //retry after syncing the memory
00146       _myDataMemoryManager->strongSynchronizeRegion(_mesDonnees->historyFifoOffset,
00147                                                     _mesDonnees->historyLength);
00148       PsMomeOutput<PsList<PsInt> > * uneCopieNonConst = const_cast< PsMomeOutput<PsList<PsInt> > *> (this);
00149       assert (uneCopieNonConst != 0 );
00150       uneCopieNonConst->extract();
00151       return PsOutput<PsList<PsInt> >::get(validiteRes,niveauInterpol,deltaT);      
00152    }
00153 }
00154 
00155 void PsMomeOutput <PsList <PsInt> >::set (const PsList< PsInt > & val) {
00156    cerr<<"PsOutput <PsList <PsInt> >::set ";
00157    const PsDate & date = Controleur ()->getSimulatedDate () ;
00158    CurrentAllocator titi(owner->Nom());
00159    assert (CurrentAllocator::name != NULL) ;
00160    if (_validity) {  //mise a jour de la valeur de l'attribut (par le referentiel owner)
00161       const PsList <PsInt> & ancValue=_history->getVal();
00162 
00163       _history->set (val, date) ;
00164 
00165       if(val!=ancValue) {
00166          notifyConnectedSensitiveInputs();
00167       }
00168    }
00169    else {
00170       _history->set (val, date) ;
00171       setValidity(true) ;
00172    }   
00173    //cerr<<" PsOutput <PsList <PsInt> >::set fin "<<endl;
00174 }
00175 
00176 

logo OpenMask

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

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