#include <PsnMomeWriterFifo.h>
Inheritance diagram for PsnMomeWriterFifo< Type >:


Public Methods | |
| PsnMomeWriterFifo (const int, PsnRelaxedMemoryManager *myMemory) | |
| PsnMomeWriterFifo (void *fifoAddress, const unsigned int size) | |
| virtual | ~PsnMomeWriterFifo () |
| virtual void | set (const Type &val, const PsDate &date) |
| add a value to the fifo | |
| virtual unsigned int | getNumberOfPresentValues (int maxCherche=-1) const |
| get the number of values in the fifo | |
| virtual void | setInPlace (const Type &val, const PsDate &date) |
| make an allready copied value available for reading | |
| virtual Type & | getNextPlaceHolder () |
| get a reference to the next place that will be used to store a value | |
| virtual void | clear () |
| clear the fifo | |
| virtual void | printDebuggingInformation () const |
| printDebuggingInformation print any usefull debugging information | |
Protected Methods | |
| virtual unsigned int | findFirstValid () const |
| find the index of the first valid value | |
| virtual const PsDate & | getOldestDateAfter (const int indice) const |
| look for the next valid date after index indice. | |
Definition at line 25 of file PsnMomeWriterFifo.h.
|
||||||||||||||||
|
Definition at line 51 of file PsnMomeWriterFifo.h.
00052 : 00053 PsnMomeFifo<Type> (size,myMemory) { 00054 |
|
||||||||||||||||
|
Definition at line 59 of file PsnMomeWriterFifo.h.
00060 : 00061 PsnMomeFifo<Type> (fifoAddress,size) { 00062 |
|
|||||||||
|
Definition at line 67 of file PsnMomeWriterFifo.h.
00068 {
00069
|
|
|||||||||
|
clear the fifo
Implements PsnMomeFifo< Type >. Definition at line 186 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::_dateOfOldestValidValue, and PsnMomeFifo< Type >::_lastValidIndex.
00187 {
00188 _dateOfOldestValidValue = (*_tab)[_lastValidIndex].dateValeur ;
00189 (*_tab)[_lastValidIndex].dateValeur -- ;
|
|
|||||||||
|
find the index of the first valid value
Implements PsnMomeFifo< Type >. Definition at line 176 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::_lastValidIndex. Referenced by PsnMomeWriterFifo< Type >::getNumberOfPresentValues().
00177 {
00178 #ifdef _DEBUGATTRIBUTSMOME
00179 cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::findFirstValid ()"<<endl;
00180 #endif
00181 return _lastValidIndex ;
|
|
|||||||||
|
get a reference to the next place that will be used to store a value
Implements PsnMomeFifo< Type >. Definition at line 116 of file PsnMomeWriterFifo.h. References PsnRelaxedMemoryManager::getWritableQueueIndex().
00118 {
00119 return (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].valeur ;
|
|
||||||||||
|
get the number of values in the fifo
Implements PsnMomeFifo< Type >. Definition at line 123 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, and PsnMomeWriterFifo< Type >::findFirstValid().
00124 {
00125 #ifdef _DEBUGATTRIBUTSMOME
00126 cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNumberOfPresentValues("<<maxCherche<<")"<<endl;
00127 #endif
00128 unsigned int nbATrouver ;
00129 if (maxCherche == -1) {
00130 nbATrouver = _fifoSize ;
00131 }
00132 else {
00133 nbATrouver = maxCherche ;
00134 }
00135 int lookAt = findFirstValid () ;
00136
00137 unsigned int nbValidFound = 0 ;
00138 unsigned int nbLookedAt = 0 ;
00139
00140 while ( ( nbValidFound < nbATrouver ) &&
00141 ( nbLookedAt < _fifoSize ) ) {
00142 if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00143 nbLookedAt++ ;
00144 if (lookAt != 0 ) {
00145 lookAt--;
00146 }
00147 else {
00148 lookAt = _fifoSize -1 ;
00149 }
00150 }
00151 return nbValidFound ;
|
|
||||||||||
|
look for the next valid date after index indice. It will become the date of the oldest valid value Definition at line 156 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_tab, and PsDate. Referenced by PsnMomeWriterFifo< Type >::set(), and PsnMomeWriterFifo< Type >::setInPlace().
00157 {
00158 //if the assertion isn't valid, the loop might never end
00159 assert ((*_tab)[i].dateValeur >= _dateOfOldestValidValue ) ;
00160
00161 int lookAt = ( i + 1 ) % _fifoSize ;
00162 int nbValidFound = 0 ;
00163
00164 if ((*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00165
00166 while (nbValidFound != 1) {
00167 lookAt = ( lookAt + 1 ) % _fifoSize ;
00168 if ((*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00169 }
00170
00171 return (*_tab) [lookAt].dateValeur ;
|
|
|||||||||
|
printDebuggingInformation print any usefull debugging information
Implements PsnMomeFifo< Type >. Definition at line 194 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::printDebuggingInformation().
00195 {
00196 cerr<<" PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::printDebuggingInformation () "<<endl;
00197 PsnMomeFifo<Type>::printDebuggingInformation() ;
|
|
||||||||||||||||
|
add a value to the fifo
Implements PsnMomeFifo< Type >. Definition at line 74 of file PsnMomeWriterFifo.h. References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnMomeWriterFifo< Type >::getOldestDateAfter(), PsnRelaxedMemoryManager::getWritableQueueIndex(), and PsDate.
00075 {
00076 #ifdef _DEBUGATTRIBUTSMOME
00077 cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::set("<<val<<", "<<date<<")"<<endl;
00078 #endif
00079 PsDate & oldDateAtWrittenIndex ((*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur) ;
00080 // cerr<<"Written at adress : "<<&(*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()]
00081 // <<" which is page : "<<PsnSharedMemoryManager::whichSharedMemoryManager(_tab)->globalAddressToLocal(&(*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()])/4096+4096
00082 // <<endl;
00083 (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].valeur = val ;
00084 //assert (oldDateAtWrittenIndex != date) ;
00085 if ( oldDateAtWrittenIndex != date ) {//avoid rechanging
00086 (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur = date ;
00087 _dateOfOldestValidValue = getOldestDateAfter (PsnRelaxedMemoryManager::getWritableQueueIndex()) ;
00088 _lastValidIndex = PsnRelaxedMemoryManager::getWritableQueueIndex() ;
00089 (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].datePlusVieilleValeurValide = _dateOfOldestValidValue ;
00090
00091 }
00092 #ifdef _DEBUGATTRIBUTSMOME
00093 cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::set done"<<endl;
00094 #endif
|
|
||||||||||||||||
| Documentation generated on Mon Nov 25 15:26:11 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |