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

PsMomeOutput< Type > Class Template Reference

Implements outputs stored in shared memory. More...

#include <PsMomeOutput.h>

Inheritance diagram for PsMomeOutput< Type >:

Inheritance graph
[legend]
Collaboration diagram for PsMomeOutput< Type >:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsMomeOutput (const PsName &outputName, PsSimulatedObject &owner, const int historyLength, PsPolatorNT *polator=NULL)
 Constructor : initialises shared data.

virtual ~PsMomeOutput (void)
 Destructor.

virtual void setValidity (bool)
 redefined so thath changes are propagated over shared memory

virtual void setUsedOutput (PsOutput< Type > *output)
 redefinition pour partager l'information

virtual void setDescendantOutput (PsOutput< Type > *output)
 redefinition pour partager l'information

virtual void extract (istream &=cin)
 redefinition d'extract pour faire la synchro de la outputMome

virtual const Type & get (int &validiteRes, const int niveauInterpol, const PsDate &deltaT, Type &resultPlaceHolder) const
 redéfinition pour attrapper l'exception PsExceptionOutputNonInitilisee

virtual void set (const Type &val)
 redefinition pour positionner les allocateurs


Protected Attributes

PsnOutputSharedData_mesDonnees
 Les données partagées de la output.

PsDate _dateDernierChangementValeur
 La date de la dernière modification connue de la valeur de la output.

PsMomeController_monControleur
 Un pointeur sur le getController.

PsnRelaxedMemoryManager_myDataMemoryManager
 Un pointeur sur le gestionnaire de mémoire de ses données.


Detailed Description

template<typename Type>
class PsMomeOutput< Type >

Implements outputs stored in shared memory.

Author:
David Margery
Version:
1.0

Definition at line 31 of file PsMomeOutput.h.


Constructor & Destructor Documentation

template<typename Type>
PsMomeOutput< Type >::PsMomeOutput const PsName   outputName,
PsSimulatedObject   owner,
const int    historyLength,
PsPolatorNT   polator = NULL
[inline]
 

Constructor : initialises shared data.

Parameters:
outputName the name of this output for it's owner
owner a reference to the owner of this output
historyLength the length of the associated history fifo
polator the associated polator

Definition at line 103 of file PsMomeOutput.h.

References PsOutput< Type >::_history, PsMomeOutput< Type >::_mesDonnees, PsMomeOutput< Type >::_monControleur, PsMomeOutput< Type >::_myDataMemoryManager, PsAttribute::_owner, PsOutput< Type >::_polator, PsMomeController::creerDonneesOutput(), PsController::error(), PsSimulatedObject::getController(), PsSimulatedObject::getName(), PsSimulatedObject::getObjectDescriptor(), PsObjectDescriptor::getProcess(), PsnSharedMemoryManager::globalAddressToLocal(), PsnOutputSharedData::historyFifoOffset, PsnSharedMemoryManager::invalidOffset(), PsnSharedMemoryManager::localAddressToGlobal(), PsnSharedMemoryManager::lockIfNeeded(), PsMomeController::outputDataSharedMemoryManager, PsnRelaxedMemoryManager::synchronizeAfterLock(), and PsnSharedMemoryManager::unlockIfNeeded().

00108    : PsAttribute(prop,nom),
00109      PsOutput<Type> (nom,prop,tailleFile,interpolateur)
00110 {
00111    //cerr<<"PsMomeOutput<Type>::PsMomeOutput "<<endl;
00112    //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
00113    delete _history;
00114 
00115    //Their is 4 cases : either we need to create a PsnMomeWriterFifo or a PsnMomeReaderFifo and either the internal data has allready been created or not
00116 
00117 
00118    _monControleur=dynamic_cast<PsMomeController *>(&_owner.getController());
00119 
00120    if (_monControleur!=NULL) {
00121 
00122       _myDataMemoryManager = PsMomeController::outputDataSharedMemoryManager;
00123 
00124       _mesDonnees = _monControleur->creerDonneesOutput(_owner.getName(),nom);
00125 
00126       _myDataMemoryManager->lockIfNeeded();
00127 
00128       _myDataMemoryManager->synchronizeAfterLock((void *)_mesDonnees,sizeof(PsnOutputSharedData));
00129 
00130       if (_myDataMemoryManager->invalidOffset(_mesDonnees->historyFifoOffset)) {
00131 
00132          if (tailleFile < _polator->getNumberOfNeededValuesForMaxPrecisionPolation() ) {
00133             cerr<<"Taille de file trop petite ("<<tailleFile
00134                 <<") alors que la output "<<nom<<" de "<<_owner.getName()
00135                 <<" nécessite "<<_polator->getNumberOfNeededValuesForMaxPrecisionPolation()
00136                 <<" valeurs pour un fonctionnement correct "<<endl;
00137             PsController::error("PsMomeOutput::constructeur");
00138          }
00139 #ifdef _DEBUGCREATIONOUTPUT
00140          cerr<<"PsMomeOutput<Type>::PsMomeOutput : creation d'une file Mome"<<endl;
00141 #endif
00142          
00143          if ( _monControleur->getObjectDescriptor().getProcess () == _owner.getObjectDescriptor().getProcess () ) {
00144             _history = new PsnMomeWriterFifo < Type > ( tailleFile , _myDataMemoryManager ) ;
00145          }
00146          else {
00147             _history = new PsnMomeReaderFifo <Type > ( tailleFile , _myDataMemoryManager ) ;
00148          }
00149 #ifdef _DEBUGCREATIONOUTPUT
00150          cerr<<"PsMomeOutput<Type>::PsMomeOutput : file Mome créée "<<endl;
00151 #endif
00152          _mesDonnees->historyFifoOffset=_myDataMemoryManager->globalAddressToLocal( ((PsnMomeFifo<Type> *)_history)->fifo() );
00153          
00154       }
00155       else {
00156          if (_monControleur->getObjectDescriptor().getProcess () == _owner.getObjectDescriptor().getProcess () ) {
00157 
00158             _history = new PsnMomeWriterFifo <Type > (_myDataMemoryManager->localAddressToGlobal(_mesDonnees->historyFifoOffset), tailleFile);
00159          }
00160          else {
00161             _history = new PsnMomeReaderFifo <Type > ( _myDataMemoryManager->localAddressToGlobal(_mesDonnees->historyFifoOffset),tailleFile); 
00162          }
00163 
00164       }
00165 
00166       _myDataMemoryManager->unlockIfNeeded();
00167       
00168    }
00169    else {
00170       cerr<<"PsMomeOutput<"<<typeid(Type).name()<<">::constructeur"
00171           <<"Controleur de type Mome attendu, mais de type "<<typeid(_owner.getController()).name()<<endl;
00172       PsController::error("");
00173    }
00174 
00175    _polator->setFifo(_history);
00176    //cerr<<"PsMomeOutput<Type>::PsMomeOutput fin de creation de la MomeOutput"<<endl;

template<typename Type>
PsMomeOutput< Type >::~PsMomeOutput void    [inline, virtual]
 

Destructor.

Definition at line 181 of file PsMomeOutput.h.

References PsOutput< Type >::_history, PsMomeOutput< Type >::_monControleur, PsAttribute::_name, PsAttribute::_owner, PsSimulatedObject::getName(), and PsMomeController::invalidateOutput().

00183 {
00184    //cerr<<"PsMomeOutput <"<<typeid(Type).name()<<">::~PsMomeOutput()"<<endl;
00185    //delete _history ;
00186    _history = NULL ;
00187    _monControleur->invalidateOutput(_owner.getName(),_name);
00188    //cerr<<"Fin destructeur de PsMomeOutput <"<<typeid(Type).name()<<">"<<endl;


Member Function Documentation

template<typename Type>
void PsMomeOutput< Type >::extract istream &    in = cin [virtual]
 

redefinition d'extract pour faire la synchro de la outputMome

L'utilisté des 3 premiers tests reste à démontrer, puisqu'on utilise un set et get pour accéder à ces valeurs

Reimplemented from PsOutput< Type >.

Definition at line 84 of file PsMomeOutput.h.

References PsMomeOutput< Type >::_mesDonnees, PsMomeOutput< Type >::_myDataMemoryManager, PsOutput< Type >::_validity, PsnOutputSharedData::_validity, PsnSharedMemoryManager::localAddressToGlobal(), PsnOutputSharedData::principalAliasDataOffset, PsMomeOutput< Type >::setValidity(), and PsnOutputSharedData::usedOutputDataOffset.

Referenced by PsMomeOutput< Type >::get().

00085                                              {
00086    //on s'en fiche de in, puisqu'on a déjà les infos sous la bonne forme !
00088    //cerr<<"PsMomeOutput<Type>::extract"<<endl;
00089    if(_myDataMemoryManager->localAddressToGlobal(_mesDonnees->usedOutputDataOffset)!=NULL){
00090       
00091    }
00092    if(_myDataMemoryManager->localAddressToGlobal(_mesDonnees->principalAliasDataOffset)!=NULL){
00093 
00094    }
00095    if(_mesDonnees->_validity!=_validity){
00096       setValidity(_mesDonnees->_validity);
00097    }
00098       

template<typename Type>
const Type & PsMomeOutput< Type >::get int &    validiteRes,
const int    niveauInterpol,
const PsDate   deltaT,
Type &    resultPlaceHolder
const [virtual]
 

redéfinition pour attrapper l'exception PsExceptionOutputNonInitilisee

Reimplemented from PsOutput< Type >.

Definition at line 219 of file PsMomeOutput.h.

References PsOutput< Type >::_history, PsMomeOutput< Type >::_myDataMemoryManager, PsAttribute::_name, PsAttribute::_owner, PsOutput< Type >::_validity, PsMomeOutput< Type >::extract(), PsOutput< Type >::get(), PsSimulatedObject::getName(), PsDate, and PsnRelaxedMemoryManager::syncStepSyncedMemory().

00224 {
00225 #ifdef _DEBUGATTRIBUTSMOME
00226    cerr<<"PsMomeOutput<"<<typeid(Type).name()<<">::"<<this<<"::get de "<<_name<<" "<<_owner.getName()<<endl;
00227    cerr<<"file : "<<_history<<endl;
00228 #endif
00229    if (! _validity) {
00230       _myDataMemoryManager->syncStepSyncedMemory();
00231       PsMomeOutput<Type> * uneCopieNonConst = const_cast< PsMomeOutput<Type> *> (this);
00232       uneCopieNonConst->extract();
00233    }
00234    try {
00235       try {
00236          return PsOutput<Type>::get(validiteRes,niveauInterpol,deltaT, resultPlaceHolder);
00237       }
00238       catch (PsUnInitialisedOutputException & s) {
00239          ((PsnMomeFifo <Type > *) _history )->resyncFifo (_myDataMemoryManager) ; 
00240          PsMomeOutput<Type> * uneAutreCopieNonConst = const_cast< PsMomeOutput<Type> *> (this);
00241          //assert (uneCopieNonConst != 0 );
00242          uneAutreCopieNonConst->extract();
00243          cerr<<"retry after syncing the memory of "<<_name<<" of object "<<_owner.getName()<<endl;
00244          return PsOutput<Type>::get(validiteRes,niveauInterpol,deltaT, resultPlaceHolder);      
00245       }
00246    }
00247    catch (PsEmptyFifoException & s) {
00248       cerr<<"PsMomeOutput<Type>::get : la file est vraiment vide !"<<endl;
00249       return PsOutput<Type>::get(validiteRes,niveauInterpol,deltaT, resultPlaceHolder);
00250    }

template<typename Type>
void PsMomeOutput< Type >::set const Type &    val [virtual]
 

redefinition pour positionner les allocateurs

Reimplemented from PsOutput< Type >.

Definition at line 254 of file PsMomeOutput.h.

References PsMomeOutput< Type >::_myDataMemoryManager, PsAttribute::_name, PsAttribute::_owner, PsSimulatedObject::getName(), and PsOutput< Type >::set().

00255                                                {
00256 #ifdef _DEBUGATTRIBUTSMOME
00257    cerr<<"PsMomeOutput<"<<typeid(Type).name()<<">::"<<this<<"set "<<_name<<" de "<<_owner.getName()<<" "<<val<<endl;
00258 #endif
00259    HeapStackTop specialContext(_myDataMemoryManager);
00260    //assert(HeapStackTop::globalMemoryManager != NULL );
00261    PsOutput< Type >::set(val) ;
00262    //cerr<<"PsMomeOutput<Type>::set fait"<<endl;

template<typename Type>
void PsMomeOutput< Type >::setDescendantOutput PsOutput< Type > *    output [virtual]
 

redefinition pour partager l'information

Definition at line 202 of file PsMomeOutput.h.

References PsMomeOutput< Type >::_mesDonnees, PsMomeOutput< Type >::_myDataMemoryManager, PsnSharedMemoryManager::globalAddressToLocal(), and PsnOutputSharedData::principalAliasDataOffset.

00203                                                                      {
00204    //PsOutput<Type>::setDescendantOutput(output);
00205    assert (false) ;
00206    PsMomeOutput<Type> * laOutput  = dynamic_cast<PsMomeOutput<Type> *>(output);
00207    _mesDonnees->principalAliasDataOffset=_myDataMemoryManager->globalAddressToLocal(laOutput->_mesDonnees);

template<typename Type>
void PsMomeOutput< Type >::setUsedOutput PsOutput< Type > *    output [virtual]
 

redefinition pour partager l'information

Reimplemented from PsOutput< Type >.

Definition at line 212 of file PsMomeOutput.h.

References PsMomeOutput< Type >::_mesDonnees, PsMomeOutput< Type >::_myDataMemoryManager, PsnSharedMemoryManager::globalAddressToLocal(), PsOutput< Type >::setUsedOutput(), and PsnOutputSharedData::usedOutputDataOffset.

00213                                                                {
00214    PsOutput<Type>::setUsedOutput(output);
00215    PsMomeOutput<Type> * laOutput  = dynamic_cast<PsMomeOutput<Type> *>(output);
00216    _mesDonnees->usedOutputDataOffset=_myDataMemoryManager->globalAddressToLocal(laOutput->_mesDonnees);

template<typename Type>
void PsMomeOutput< Type >::setValidity bool    [virtual]
 

redefined so thath changes are propagated over shared memory

Reimplemented from PsOutput< Type >.

Definition at line 193 of file PsMomeOutput.h.

References PsMomeOutput< Type >::_mesDonnees, PsnOutputSharedData::_validity, and PsOutput< Type >::setValidity().

Referenced by PsMomeOutput< Type >::extract().


Member Data Documentation

template<typename Type>
PsDate PsMomeOutput< Type >::_dateDernierChangementValeur [protected]
 

La date de la dernière modification connue de la valeur de la output.

Sert à gérer les entrées sensibles lors de la synchronisation

Definition at line 70 of file PsMomeOutput.h.

template<typename Type>
PsnOutputSharedData* PsMomeOutput< Type >::_mesDonnees [protected]
 

Les données partagées de la output.

Definition at line 67 of file PsMomeOutput.h.

Referenced by PsMomeOutput< Type >::extract(), PsMomeOutput< Type >::PsMomeOutput(), PsMomeOutput< Type >::setDescendantOutput(), PsMomeOutput< Type >::setUsedOutput(), and PsMomeOutput< Type >::setValidity().

template<typename Type>
PsMomeController* PsMomeOutput< Type >::_monControleur [protected]
 

Un pointeur sur le getController.

Definition at line 72 of file PsMomeOutput.h.

Referenced by PsMomeOutput< Type >::PsMomeOutput(), and PsMomeOutput< Type >::~PsMomeOutput().

template<typename Type>
PsnRelaxedMemoryManager* PsMomeOutput< Type >::_myDataMemoryManager [protected]
 

Un pointeur sur le gestionnaire de mémoire de ses données.

Definition at line 74 of file PsMomeOutput.h.

Referenced by PsMomeOutput< Type >::extract(), PsMomeOutput< Type >::get(), PsMomeOutput< Type >::PsMomeOutput(), PsMomeOutput< Type >::set(), PsMomeOutput< Type >::setDescendantOutput(), and PsMomeOutput< Type >::setUsedOutput().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:10 2002

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