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

PsnMomeFifo< Type > Class Template Reference

create the illusion of a Fifo over shared memory More...

#include <PsnMomeFifo.h>

Inheritance diagram for PsnMomeFifo< Type >:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnMomeFifo (const unsigned int, PsnRelaxedMemoryManager *myMemory)
 PsnMomeFifo (void *fifoAddress, const unsigned int)
virtual ~PsnMomeFifo ()
virtual void set (const Type &val, const PsDate &date)=0
 add a value to the fifo

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

virtual const Type & getPreceedingValue (const unsigned int indice) const
 get a value before the current value

virtual const PsDategetPreceedingDate (const unsigned int indice) const
 get the date associated to a value before the current value

virtual void setInPlace (const Type &val, const PsDate &date)=0
 make an allready copied value available for reading

virtual Type & getNextPlaceHolder ()=0
 get a reference to the next place that will be used to store a value

virtual void clear ()=0
 clear the fifo

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

void * fifo ()
virtual void resyncFifo (PsnRelaxedMemoryManager *myMemory) const

Protected Methods

virtual unsigned int findFirstValid () const=0

Protected Attributes

PsnAbstractArray< valeurDate > * _tab
 the array in wich the values are kept

PsDate _dateOfOldestValidValue
 the date of the oldest valid value localy available

unsigned int _lastValidIndex
unsigned int _offsetToMostRecentOfLastExamined
 Context variable.

unsigned int _indexOfLastValueExamined
 Context variable.

PsnMutexLock _accessToContext
 a lock to protect acces to the context


Detailed Description

template<typename Type>
class PsnMomeFifo< Type >

create the illusion of a Fifo over shared memory

Definition at line 40 of file PsnMomeFifo.h.


Constructor & Destructor Documentation

template<typename Type>
PsnMomeFifo< Type >::PsnMomeFifo const unsigned    int,
PsnRelaxedMemoryManager   myMemory
 

Definition at line 197 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnRelaxedMemoryManager::getReadableQueueIndex(), and PsDate.

00198                                                                                              : PsnAbstractFifo<Type>(taille), _offsetToMostRecentOfLastExamined(taille) {
00199    
00200    myMemory->lockIfNeeded ( ) ;
00201    
00202    _tab = new(myMemory) PsnMomeArray< valeurDate > ( taille, *myMemory) ;
00203    
00204    myMemory->unlockIfNeeded ( ) ;
00205 
00206    _dateOfOldestValidValue = PsDate ( -1 ); 
00207    _lastValidIndex = ( PsnRelaxedMemoryManager::getReadableQueueIndex() - 1 + _fifoSize ) % _fifoSize ;

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

Definition at line 212 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnRelaxedMemoryManager::getReadableQueueIndex(), and PsDate.

00214    : PsnAbstractFifo<Type>(taille), 
00215    _offsetToMostRecentOfLastExamined(taille) {
00216    
00217    _tab =  (PsnMomeArray< valeurDate > * ) fifoAddress ;
00218    
00219    _dateOfOldestValidValue = PsDate ( -1 ); 
00220 
00221    _lastValidIndex = ( PsnRelaxedMemoryManager::getReadableQueueIndex() - 1 + _fifoSize ) % _fifoSize ;

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

Definition at line 190 of file PsnMomeFifo.h.

00191                                  {
00192 #ifdef _DEBUGEXEC
00193    cerr<<"PsnMomeFifo<Type>::~PsnMomeFifo ()"<<endl;
00194 #endif


Member Function Documentation

template<typename Type>
virtual void PsnMomeFifo< Type >::clear   [pure virtual]
 

clear the fifo

Implements PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

template<typename Type>
void * PsnMomeFifo< Type >::fifo  
 

Definition at line 111 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_tab.

00112                                {
00113    return (void *)_tab ;

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

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

Referenced by PsnMomeFifo< Type >::getPreceedingDate(), and PsnMomeFifo< Type >::getPreceedingValue().

template<typename Type>
virtual Type& PsnMomeFifo< Type >::getNextPlaceHolder   [pure virtual]
 

get a reference to the next place that will be used to store a value

Implements PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

template<typename Type>
virtual unsigned int PsnMomeFifo< Type >::getNumberOfPresentValues int    maxCherche = -1 const [pure 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 PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

template<typename Type>
const PsDate & PsnMomeFifo< Type >::getPreceedingDate const unsigned int    indice const [virtual]
 

get the date associated to a value before the current value

Parameters:
index if 0, get the date of the most recent value, if 1, get the date associated to the preceeding value...

Implements PsnAbstractFifo< Type >.

Definition at line 158 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::findFirstValid(), PsnMomeFifo< Type >::printDebuggingInformation(), and PsDate.

00159                                                                                                 {
00160 #ifdef _DEBUGATTRIBUTSMOME
00161    cerr<<"PsnMomeFifo<"<<typeid(Type).name()<<">::"<<this<<"::getPreceedingDate ("<<offsetToMostRecent<<") const"<<endl;
00162    printDebuggingInformation();
00163 #endif
00164 
00165    assert (offsetToMostRecent >= 0) ;
00166 
00167    if (offsetToMostRecent > 4) cerr<<"C'est anormal de demander à "<<offsetToMostRecent<<endl;
00168    assert (offsetToMostRecent < _fifoSize - 2) ;
00169 
00170    int lookAt = findFirstValid () ;
00171    unsigned int offsetToMostRecentOfLastExamined = -1 ;
00172 
00173    if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) offsetToMostRecentOfLastExamined++ ;
00174 
00175    
00176    while ( offsetToMostRecentOfLastExamined != offsetToMostRecent ) {
00177       if ( lookAt != 0 ) {
00178          lookAt--;
00179       }
00180       else {
00181          lookAt = _fifoSize - 1 ;
00182       }
00183       
00184       if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) offsetToMostRecentOfLastExamined++ ;
00185    }
00186 
00187    return (*_tab)[lookAt].dateValeur ;

template<typename Type>
const Type & PsnMomeFifo< Type >::getPreceedingValue const unsigned int    indice const [virtual]
 

get a value before the current value

Parameters:
index if 0, get the most recent value, if 1, get the preceeding value...

Implements PsnAbstractFifo< Type >.

Definition at line 116 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::findFirstValid(), and PsnMomeFifo< Type >::printDebuggingInformation().

00117                                                                                                {
00118 #ifdef _DEBUGATTRIBUTSMOME
00119    cerr<<"PsnMomeFifo<"<<typeid(Type).name()<<">::"<<this<<"::getPreceedingValue ("<<offsetToMostRecent<<") const"<<endl;
00120 #endif
00121 
00122    assert (offsetToMostRecent >= 0) ;
00123    assert (offsetToMostRecent < _fifoSize - 2 ) ;
00124 
00125    int lookAt = findFirstValid () ;
00126 #ifdef _DEBUGATTRIBUTSMOME
00127    cerr<<"First valid is : "<<lookAt<<endl;
00128    printDebuggingInformation() ;
00129 #endif
00130 
00131    unsigned int offsetToMostRecentOfLastFound = -1 ;
00132 
00133    if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) offsetToMostRecentOfLastFound++ ;
00134 
00135    while ( offsetToMostRecentOfLastFound != offsetToMostRecent ) {
00136       if ( lookAt != 0 ) {
00137          lookAt--;
00138       }
00139       else {
00140          lookAt = _fifoSize - 1 ;
00141       }
00142       
00143       if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) offsetToMostRecentOfLastFound++ ;
00144    }
00145 
00146    return (*_tab)[lookAt].valeur ;

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

printDebuggingInformation print any usefull debugging information

Implements PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

Definition at line 101 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnAbstractArray< valeurDate >::printDebuggingInformation(), and PsnAbstractFifo< Type >::printDebuggingInformation().

Referenced by PsnMomeFifo< Type >::getPreceedingDate(), PsnMomeFifo< Type >::getPreceedingValue(), PsnMomeWriterFifo< Type >::printDebuggingInformation(), and PsnMomeReaderFifo< Type >::printDebuggingInformation().

00102                                                         {
00103    PsnAbstractFifo<Type>::printDebuggingInformation() ;
00104    cerr<<"Valeur du tableau : "<<endl;
00105    _tab->printDebuggingInformation (_fifoSize) ;
00106    cerr<<"_dateOfOldestValidValue : "<<_dateOfOldestValidValue<<endl;
00107    cerr<<"_lastValidIndex : "<<_lastValidIndex<<endl;

template<typename Type>
void PsnMomeFifo< Type >::resyncFifo PsnRelaxedMemoryManager   myMemory const [virtual]
 

Definition at line 150 of file PsnMomeFifo.h.

References PsnMomeFifo< Type >::_tab.

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

00151                                                                              {
00152    ((PsnMomeArray<valeurDate> *) _tab )->resync( myMemory ) ;

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

add a value to the fifo

Implements PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.

template<typename Type>
virtual void PsnMomeFifo< Type >::setInPlace const Type &    val,
const PsDate   date
[pure virtual]
 

make an allready copied value available for reading

Implements PsnAbstractFifo< Type >.

Implemented in PsnMomeReaderFifo< Type >, and PsnMomeWriterFifo< Type >.


Member Data Documentation

template<typename Type>
PsnMutexLock PsnMomeFifo< Type >::_accessToContext [mutable, protected]
 

a lock to protect acces to the context

Definition at line 92 of file PsnMomeFifo.h.

template<typename Type>
PsDate PsnMomeFifo< Type >::_dateOfOldestValidValue [mutable, protected]
 

the date of the oldest valid value localy available

Definition at line 84 of file PsnMomeFifo.h.

Referenced by PsnMomeWriterFifo< Type >::clear(), PsnMomeWriterFifo< Type >::getNumberOfPresentValues(), PsnMomeReaderFifo< Type >::getNumberOfPresentValues(), PsnMomeWriterFifo< Type >::getOldestDateAfter(), PsnMomeFifo< Type >::getPreceedingDate(), PsnMomeFifo< Type >::getPreceedingValue(), PsnMomeFifo< Type >::printDebuggingInformation(), PsnMomeFifo< Type >::PsnMomeFifo(), PsnMomeWriterFifo< Type >::set(), and PsnMomeWriterFifo< Type >::setInPlace().

template<typename Type>
unsigned int PsnMomeFifo< Type >::_indexOfLastValueExamined [mutable, protected]
 

Context variable.

Definition at line 90 of file PsnMomeFifo.h.

template<typename Type>
unsigned int PsnMomeFifo< Type >::_lastValidIndex [mutable, protected]
 

Definition at line 85 of file PsnMomeFifo.h.

Referenced by PsnMomeWriterFifo< Type >::clear(), PsnMomeWriterFifo< Type >::findFirstValid(), PsnMomeReaderFifo< Type >::findFirstValid(), PsnMomeReaderFifo< Type >::getNumberOfPresentValues(), PsnMomeFifo< Type >::printDebuggingInformation(), PsnMomeFifo< Type >::PsnMomeFifo(), PsnMomeWriterFifo< Type >::set(), and PsnMomeWriterFifo< Type >::setInPlace().

template<typename Type>
unsigned int PsnMomeFifo< Type >::_offsetToMostRecentOfLastExamined [mutable, protected]
 

Context variable.

Definition at line 88 of file PsnMomeFifo.h.

template<typename Type>
PsnAbstractArray<valeurDate>* PsnMomeFifo< Type >::_tab [protected]
 

the array in wich the values are kept

Definition at line 81 of file PsnMomeFifo.h.

Referenced by PsnMomeFifo< Type >::fifo(), PsnMomeWriterFifo< Type >::getOldestDateAfter(), PsnMomeReaderFifo< Type >::printDebuggingInformation(), PsnMomeFifo< Type >::printDebuggingInformation(), PsnMomeFifo< Type >::PsnMomeFifo(), PsnMomeFifo< Type >::resyncFifo(), PsnMomeWriterFifo< Type >::set(), and PsnMomeWriterFifo< Type >::setInPlace().


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

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

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