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


Public Methods | |
| PsnFifo (const int taille) | |
| constructor | |
| virtual | ~PsnFifo () |
| destructor | |
| virtual const Type & | getPreceedingValue (const unsigned int indice) const |
| get a value before the current value | |
| virtual const PsDate & | getPreceedingDate (const unsigned int indice) const |
| get the date associated to a value before the current value | |
| virtual void | set (const Type &val, const PsDate &date) |
| add a value to 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 file | |
| virtual unsigned int | getNumberOfPresentValues (int maxCherche=-1) const |
| get the number of values in the fifo | |
| virtual void | printDebuggingInformation (void) const |
| printDebuggingInformation print any usefull debugging information | |
Protected Attributes | |
| PsnAbstractArray< valeurDate > * | _tab |
| the array in wich the values are kept | |
| unsigned int | _numberOfValues |
| the number of valid values in _tab | |
| unsigned int | _mostRecentValueIndex |
| the place the most recent value was stored | |
Definition at line 30 of file PsnFifo.h.
|
||||||||||
|
constructor
Definition at line 105 of file PsnFifo.h. References PsnFifo< Type >::_tab.
00105 : 00106 PsnAbstractFifo <Type> (taille), 00107 _numberOfValues ( 0 ), 00108 _mostRecentValueIndex (taille-1) 00109 { 00110 _tab = new PsnArray < valeurDate > (taille) ; 00111 //cerr<<"PsnFifo<Type>::PsnFifo created "<<endl; 00112 } |
|
|||||||||
|
destructor
Definition at line 117 of file PsnFifo.h. References PsnFifo< Type >::_tab.
|
|
|||||||||
|
clear the file
Implements PsnAbstractFifo< Type >. Definition at line 209 of file PsnFifo.h. References PsnFifo< Type >::_numberOfValues.
00209 {
00210 _numberOfValues = 0 ;
00211 }
|
|
|||||||||
|
get a reference to the next place that will be used to store a value
Implements PsnAbstractFifo< Type >. Definition at line 184 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, and PsnFifo< Type >::_mostRecentValueIndex.
00185 {
00186 return (*_tab)[( _mostRecentValueIndex + 1 ) % _fifoSize].valeur ;
00187 }
|
|
||||||||||
|
get the number of values in the fifo
Implements PsnAbstractFifo< Type >. Definition at line 190 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, and PsnFifo< Type >::_numberOfValues.
00190 {
00191 unsigned int res ;
00192 if ( (maxCherche == -1) || (_numberOfValues < (unsigned int) maxCherche) ) {
00193 res = _numberOfValues ;
00194 }
00195 else {
00196 res = maxCherche ;
00197 }
00198 //for multithreading reasons, limit the results to _fifoSize - 2
00199 assert (_fifoSize >= 2) ;
00200 if (res >= _fifoSize - 1) {
00201 res = _fifoSize - 2 ;
00202 }
00203 return res ;
00204 }
|
|
||||||||||
|
get the date associated to a value before the current value
Implements PsnAbstractFifo< Type >. Definition at line 124 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, PsnFifo< Type >::_mostRecentValueIndex, and PsDate.
00125 {
00126 assert ( i < _fifoSize - 2 ) ;
00127 int indice = (_fifoSize + _mostRecentValueIndex - i ) % _fifoSize ;
00128 return (*_tab) [indice].dateValeur ;
00129 }
|
|
||||||||||
|
get a value before the current value
Implements PsnAbstractFifo< Type >. Definition at line 132 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, and PsnFifo< Type >::_mostRecentValueIndex.
00132 {
00133 assert ( i < _fifoSize - 2 ) ;
00134 int indice = (_fifoSize + _mostRecentValueIndex - i ) % _fifoSize ;
00135 return (*_tab) [indice].valeur ;
00136 }
|
|
||||||||||
|
printDebuggingInformation print any usefull debugging information
Implements PsnAbstractFifo< Type >. Definition at line 216 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, PsnFifo< Type >::_mostRecentValueIndex, PsnFifo< Type >::_numberOfValues, PsnFifo< Type >::_tab, PsnAbstractArray< valeurDate >::printDebuggingInformation(), and PsnAbstractFifo< Type >::printDebuggingInformation().
00216 {
00217 cerr<< "PsnFifo<"<<typeid(Type).name()<<">::"<<this<<"::printDebuggingInformation()"<<endl ;
00218 PsnAbstractFifo<Type>::printDebuggingInformation() ;
00219 cerr << "number of valid values : " << _numberOfValues << endl
00220 << "last written value at : " << _mostRecentValueIndex << endl
00221 << "values stored in array : "<< endl;
00222 _tab->printDebuggingInformation( _fifoSize ) ;
00223 }
|
|
||||||||||||||||
|
add a value to the fifo
Implements PsnAbstractFifo< Type >. Definition at line 141 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, PsnFifo< Type >::_mostRecentValueIndex, PsnFifo< Type >::_numberOfValues, PsnFifo< Type >::_tab, and PsDate.
00141 {
00142 //cerr<<"PsnFifo<"<<typeid(Type).name()<<">::"<<this<<"::set("<<newValue<<", "<<dateOfNewValue<<")"<<endl;
00143 unsigned int newMostRecentValueIndex = ( _mostRecentValueIndex + 1 ) % _fifoSize ;
00144
00145 PsDate & dateOfMostRecentValue((*_tab)[_mostRecentValueIndex].dateValeur) ;
00146
00147 if (dateOfMostRecentValue < dateOfNewValue ) {
00148 (*_tab)[newMostRecentValueIndex].dateValeur = dateOfNewValue ;
00149 if ( _numberOfValues != _fifoSize ) {
00150 _numberOfValues ++ ;
00151 }
00152 }
00153
00154 //cerr<<"newValue "<<newValue <<", old Value"<<(*_tab)[newMostRecentValueIndex].valeur<<endl;
00155 (*_tab)[newMostRecentValueIndex].valeur = newValue ;
00156 //cerr<<"newValue "<<(*_tab)[newMostRecentValueIndex].valeur <<endl;
00157
00158 _mostRecentValueIndex = newMostRecentValueIndex ;
00159 }
|
|
||||||||||||||||
|
make an allready copied value available for reading
Implements PsnAbstractFifo< Type >. Definition at line 162 of file PsnFifo.h. References PsnAbstractFifo< Type >::_fifoSize, PsnFifo< Type >::_mostRecentValueIndex, PsnFifo< Type >::_numberOfValues, PsnFifo< Type >::_tab, and PsDate.
00163 {
00164 unsigned int newMostRecentValueIndex = ( _mostRecentValueIndex + 1 ) % _fifoSize ;
00165
00166 PsDate & dateOfMostRecentValue((*_tab)[_mostRecentValueIndex].dateValeur) ;
00167
00168 if (dateOfMostRecentValue < dateOfNewValue ) {
00169 (*_tab)[newMostRecentValueIndex].dateValeur = dateOfNewValue ;
00170 if ( _numberOfValues != _fifoSize ) {
00171 _numberOfValues ++ ;
00172 }
00173 }
00174
00175 //this assertion will fail if setInplace is used a a different simulation step than getNextPlaceHolder
00176 // or if newValue isn't a reference to a value of the container
00177 assert (&((*_tab)[newMostRecentValueIndex].valeur) == &newValue ) ;
00178
00179 _mostRecentValueIndex = newMostRecentValueIndex ;
00180 }
|
|
|||||
|
the place the most recent value was stored
Definition at line 95 of file PsnFifo.h. Referenced by PsnFifo< Type >::getNextPlaceHolder(), PsnFifo< Type >::getPreceedingDate(), PsnFifo< Type >::getPreceedingValue(), PsnFifo< Type >::printDebuggingInformation(), PsnFifo< Type >::set(), and PsnFifo< Type >::setInPlace(). |
|
|||||
|
the number of valid values in _tab
Definition at line 92 of file PsnFifo.h. Referenced by PsnFifo< Type >::clear(), PsnFifo< Type >::getNumberOfPresentValues(), PsnFifo< Type >::printDebuggingInformation(), PsnFifo< Type >::set(), and PsnFifo< Type >::setInPlace(). |
|
|||||
|
the array in wich the values are kept
Definition at line 89 of file PsnFifo.h. Referenced by PsnFifo< Type >::printDebuggingInformation(), PsnFifo< Type >::PsnFifo(), PsnFifo< Type >::set(), PsnFifo< Type >::setInPlace(), and PsnFifo< Type >::~PsnFifo(). |
| Documentation generated on Mon Nov 25 15:26:00 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |