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

PsnMomeReaderFifo< Type > Class Template Reference

An implementation of the Fifo for Mome when the Fifo is read and never written. More...

#include <PsnMomeReaderFifo.h>

Inheritance diagram for PsnMomeReaderFifo< Type >:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnMomeReaderFifo (const int size, PsnRelaxedMemoryManager *myMemory)
 PsnMomeReaderFifo (void *fifoAddress, const unsigned int size)
virtual ~PsnMomeReaderFifo ()
virtual void set (const Type &val, const PsDate &date)
 shouldn't be used (this is a reader !)

virtual void setInPlace (const Type &newValue, const PsDate &date)
 shouldn't be used (this is a reader !)

virtual Type & getNextPlaceHolder ()
 shouldn't be used (this is a reader !)

unsigned int getNumberOfPresentValues (int maxCherche=-1) const
 get the number of values in the fifo

virtual void clear ()
 clear the fifo

virtual void printDebuggingInformation () const
 printDebuggingInformation print any usefull debugging information


Protected Methods

unsigned int findFirstValid () const

Protected Attributes

PsDate _dateOfLastValidIndex

Detailed Description

template<typename Type>
class PsnMomeReaderFifo< Type >

An implementation of the Fifo for Mome when the Fifo is read and never written.

Definition at line 24 of file PsnMomeReaderFifo.h.


Constructor & Destructor Documentation

template<typename Type>
PsnMomeReaderFifo< Type >::PsnMomeReaderFifo const int    size,
PsnRelaxedMemoryManager   myMemory
 

Definition at line 50 of file PsnMomeReaderFifo.h.

References PsDate.

00050                                                                                              : 
00051    PsnMomeFifo<Type> (size,myMemory),
00052    _dateOfLastValidIndex ( PsDate ( -3 ) ) {
00053 
00054 }

template<typename Type>
PsnMomeReaderFifo< Type >::PsnMomeReaderFifo void *    fifoAddress,
const unsigned int    size
 

Definition at line 59 of file PsnMomeReaderFifo.h.

References PsDate.

00059                                                                                       : 
00060    PsnMomeFifo<Type> (fifoAddress,size),
00061    _dateOfLastValidIndex ( PsDate ( -3 ) ) {
00062 
00063 }

template<typename Type>
PsnMomeReaderFifo< Type >::~PsnMomeReaderFifo   [virtual]
 

Definition at line 68 of file PsnMomeReaderFifo.h.

00068                                             {
00069 
00070 }


Member Function Documentation

template<typename Type>
void PsnMomeReaderFifo< Type >::clear   [virtual]
 

clear the fifo

Implements PsnMomeFifo< Type >.

Definition at line 230 of file PsnMomeReaderFifo.h.

00230                                      {
00231    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::clear() : double écrivain ! "<<endl;
00232    assert (false) ;
00233 }

template<typename Type>
unsigned int PsnMomeReaderFifo< Type >::findFirstValid   const [protected, virtual]
 

Implements PsnMomeFifo< Type >.

Definition at line 75 of file PsnMomeReaderFifo.h.

References PsnMomeReaderFifo< Type >::_dateOfLastValidIndex, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_lastValidIndex, and PsnRelaxedMemoryManager::getReadableQueueIndex().

Referenced by PsnMomeReaderFifo< Type >::getNumberOfPresentValues().

00075                                                            {
00076 #ifdef _DEBUGATTRIBUTSMOME
00077    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::findFirstValid ()"<<endl;
00078 #endif
00079    //findFirstValid only works if _dateOfLastValidIndex and _lastValidIndex have been correctly initialised with a correct pair of values and therefore (*tab)[_lastValidIndex] contains a valid value. This is always true, because nbValues() should be called before this member function is called. if it hasn't been called with a return result greater than 0, then _dateOfLastValidIndex keeps its initial value, explaining the following assertion.
00080    assert ( _dateOfLastValidIndex != -3 ) ;
00081 
00082    unsigned int lookAt = PsnRelaxedMemoryManager::getReadableQueueIndex() ;
00083 
00084    while ( ((*_tab)[lookAt].dateValeur < _dateOfLastValidIndex) && 
00085            ( lookAt != _lastValidIndex ) ) {
00086       lookAt = (lookAt - 1 + _fifoSize) % _fifoSize ;
00087 
00088    }
00089 
00090 //     if (lookAt != _lastValidIndex) {
00091 //        _lastValidIndex = lookAt ;
00092 //        _dateOfLastValidIndex = (*_tab)[lookAt].dateValeur ;
00093 //        _dateOfOldestValidValue = (*_tab)[lookAt].datePlusVieilleValeurValide ;
00094 //     }
00095 #ifdef _DEBUGATTRIBUTSMOME
00096    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::findFirstValid () = "<<lookAt<<" : "<<(*_tab)[lookAt].valeur<<endl;
00097 #endif
00098    return lookAt ;
00099 
00100 }

template<typename Type>
Type & PsnMomeReaderFifo< Type >::getNextPlaceHolder   [virtual]
 

shouldn't be used (this is a reader !)

Implements PsnMomeFifo< Type >.

Definition at line 222 of file PsnMomeReaderFifo.h.

00223 {
00224    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNextPlaceHolder () : double écrivain ! "<<endl;
00225    assert (false) ;
00226 }

template<typename Type>
unsigned int PsnMomeReaderFifo< Type >::getNumberOfPresentValues int    maxCherche = -1 const [virtual]
 

get the number of values in the fifo

Parameters:
lookingFor the number of values the caller is looking for. If == -1, get all values, otherwise, once lookingFor values are found, that number is returned

Implements PsnMomeFifo< Type >.

Definition at line 105 of file PsnMomeReaderFifo.h.

References PsnMomeReaderFifo< Type >::_dateOfLastValidIndex, PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeReaderFifo< Type >::findFirstValid(), PsnRelaxedMemoryManager::getReadableQueueIndex(), and PsnMomeReaderFifo< Type >::printDebuggingInformation().

00105                                                                                     {
00106 #if defined (_DEBUGRELAXEDCOHERANCE) || defined (_DEBUGATTRIBUTSMOME)
00107    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNumberOfPresentValues("<<maxCherche<<") "<<endl;
00108    printDebuggingInformation() ;
00109 #endif 
00110 
00111    bool onLoop = true ;
00112    unsigned int nbATrouver ;
00113    if (maxCherche == -1) {
00114       nbATrouver = _fifoSize ;
00115    }
00116    else {
00117       nbATrouver = maxCherche ; 
00118    }
00119    int lookAt ;
00120    if (_dateOfLastValidIndex != -3 ) {
00121       lookAt = findFirstValid () ;
00122    }
00123    else {
00124       lookAt = PsnRelaxedMemoryManager::getReadableQueueIndex() ;
00125    }
00126    unsigned int nbValidFound = 0 ;
00127 
00128 #if defined (_DEBUGRELAXEDCOHERANCE) || defined (_DEBUGATTRIBUTSMOME)
00129    cerr<<"  lookingAt "<<lookAt<<endl;
00130    cerr<<"   "<<lookAt<<" : "<<(*_tab)[lookAt].dateValeur<<" "<<(*_tab)[lookAt].datePlusVieilleValeurValide<<" "<<_dateOfOldestValidValue<<" "<<nbValidFound<<endl;
00131 #endif
00132 
00133    if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) {
00134       //if (lookAt != _lastValidIndex) {
00135          _lastValidIndex = lookAt ;
00136          _dateOfLastValidIndex = (*_tab)[lookAt].dateValeur ;
00137          _dateOfOldestValidValue = (*_tab)[lookAt].datePlusVieilleValeurValide ;
00138          //}
00139       long preceedingDate = _dateOfLastValidIndex ;
00140       nbValidFound++ ;
00141       //cerr<<(*_tab)[lookAt].valeur<<" "<<(*_tab)[lookAt].dateValeur<<endl;
00142       if (lookAt != 0 ) {
00143          lookAt--;
00144       }
00145       else {
00146          lookAt = _fifoSize -1 ;
00147       }
00148       while ( ( nbValidFound < nbATrouver) &&
00149               (lookAt != PsnRelaxedMemoryManager::getReadableQueueIndex() ) &&
00150               onLoop
00151               ) {
00152          if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) {
00153             if ( (*_tab)[lookAt].dateValeur < preceedingDate ) {
00154                nbValidFound++ ;
00155                preceedingDate = (*_tab)[lookAt].dateValeur ;
00156             }
00157             else {
00158                onLoop = false ;
00159             }
00160          }
00161          if (lookAt != 0 ) {
00162             lookAt--;
00163          }
00164          else {
00165             lookAt = _fifoSize -1 ;
00166          }
00167       }
00168    }
00169    else {//the FIFO is still being initialised or is corrupt. try to find a valid value in it.
00170       unsigned int nbLookedAt = 1 ;
00171       while (nbLookedAt < _fifoSize) {
00172          if (lookAt != 0 ) {
00173             lookAt--;
00174          }
00175          else {
00176             lookAt = _fifoSize -1 ;
00177          }
00178          if ( (*_tab)[lookAt].dateValeur >=  _dateOfOldestValidValue ) {
00179             nbValidFound++ ;
00180             nbLookedAt = _fifoSize ;
00181 #ifdef _DEBUGATTRIBUTSMOME
00182             cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNumberOfPresentValues : "
00183                 <<"initialising the FIFO's data"<<endl;
00184             printDebuggingInformation();
00185 #endif
00186             //initialise the FIFO's data
00187             _lastValidIndex = lookAt ;
00188             _dateOfLastValidIndex = (*_tab)[lookAt].dateValeur ;
00189             _dateOfOldestValidValue = (*_tab)[lookAt].datePlusVieilleValeurValide ;
00190          }
00191          else {
00192             nbLookedAt++ ;
00193          }
00194       }
00195    }
00196 #if defined (_DEBUGRELAXEDCOHERANCE) || defined (_DEBUGATTRIBUTSMOME)
00197      cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNumberOfPresentValues = "<<nbValidFound<<endl;
00198 #endif
00199    return nbValidFound ;
00200 }

template<typename Type>
void PsnMomeReaderFifo< Type >::printDebuggingInformation   const [virtual]
 

printDebuggingInformation print any usefull debugging information

Implements PsnMomeFifo< Type >.

Definition at line 238 of file PsnMomeReaderFifo.h.

References PsnMomeReaderFifo< Type >::_dateOfLastValidIndex, PsnMomeFifo< Type >::_tab, PsnRelaxedMemoryManager::getReadableQueueIndex(), PsnMomeFifo< Type >::printDebuggingInformation(), PsnMomeFifo< Type >::resyncFifo(), and PsnMemoryManager::whichMemoryManager().

Referenced by PsnMomeReaderFifo< Type >::getNumberOfPresentValues().

00238                                                                {
00239    cerr<<" PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::printDebuggingInformation () "<<endl;
00240    PsnMomeFifo<Type>::printDebuggingInformation() ;
00241    cerr<<"_dateOfLastValidIndex : "<<_dateOfLastValidIndex<<endl;
00242    cerr<<"readableIndex : "<<PsnRelaxedMemoryManager::getReadableQueueIndex()<<endl; 
00243    cerr<<"Réaffichage après une vrai synchronisation"<<endl;
00244    resyncFifo( ( PsnRelaxedMemoryManager *)PsnMemoryManager::whichMemoryManager(_tab) ) ;
00245    PsnMomeFifo<Type>::printDebuggingInformation() ;   
00246 }

template<typename Type>
void PsnMomeReaderFifo< Type >::set const Type &    val,
const PsDate   date
[virtual]
 

shouldn't be used (this is a reader !)

Implements PsnMomeFifo< Type >.

Definition at line 206 of file PsnMomeReaderFifo.h.

References PsDate.

00206                                                                         {
00207    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::set ("<<val<<", "<<date<<") : double écrivain ! "<<endl;
00208    assert (false) ;
00209 }

template<typename Type>
void PsnMomeReaderFifo< Type >::setInPlace const Type &    newValue,
const PsDate   date
[virtual]
 

shouldn't be used (this is a reader !)

Implements PsnMomeFifo< Type >.

Definition at line 213 of file PsnMomeReaderFifo.h.

References PsDate.

00214 {
00215    cerr<<"PsnMomeReaderFifo<"<<typeid(Type).name()<<">::"<<this<<"::setInPlace ("<<newValue<<", "<<date<<") : double écrivain ! "<<endl;
00216    assert (false) ;
00217 
00218 }


Member Data Documentation

template<typename Type>
PsDate PsnMomeReaderFifo< Type >::_dateOfLastValidIndex [mutable, protected]
 

Definition at line 45 of file PsnMomeReaderFifo.h.

Referenced by PsnMomeReaderFifo< Type >::findFirstValid(), PsnMomeReaderFifo< Type >::getNumberOfPresentValues(), and PsnMomeReaderFifo< Type >::printDebuggingInformation().


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

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

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