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

PsnAbstractFifo.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license 
00016  *
00017  */
00018 #ifndef PsnAbstractFifoHEADER
00019 #define PsnAbstractFifoHEADER
00020 
00021 #include <PsNumericType.h>
00022 
00023 
00028 template <typename Type>
00029 class PsnAbstractFifo : public PsFlowable
00030 {
00031   
00032 public :
00034    PsnAbstractFifo (const int taille) ;
00035 
00036 
00038    virtual ~PsnAbstractFifo () ;
00039 
00040 
00042    virtual int getMaximumNumberOfValues() const ;
00043 
00044 
00047    virtual unsigned int getNumberOfPresentValues( int lookingFor = -1 ) const = 0 ;
00048 
00049 
00053    virtual const Type & getPreceedingValue (const unsigned int index) const = 0 ;
00054 
00055 
00059    virtual const PsDate & getPreceedingDate(const unsigned int indice) const = 0 ;
00060    
00061 
00063    virtual void set (const Type & val, const PsDate & date) = 0 ;
00064 
00065 
00067    virtual void setInPlace ( const Type & val, const PsDate & date) = 0 ;
00068 
00069 
00071    virtual Type & getNextPlaceHolder() = 0 ;
00072 
00073 
00075    virtual void clear () = 0 ;
00076 
00077 
00079    virtual void printDebuggingInformation(void) const = 0 ;
00080 
00081 
00084    virtual void extract (istream & = cin) ;
00085    
00086 
00089    virtual void insertInStream (ostream & = cout) const  ;
00090   
00092    virtual void unpack (PsIncomingSynchronisationMessage &) ;
00093    
00095    virtual void pack (PsOutgoingSynchronisationMessage &) const ;
00096 
00098    virtual void unpackAllValues (PsIncomingSynchronisationMessage &) ;
00099    
00101    virtual void packAllValues (PsOutgoingSynchronisationMessage &) const ;
00102 
00103 protected :
00105    unsigned int _fifoSize ;
00106 
00107 } ; // PsnAbstractFifo
00108 
00109 
00110 //because everything is template, #include all the Existing FIFO here. 
00111 
00112 #include <PsnFifo.h>
00113 
00114 #if defined(_MOME) || !defined(_SGI)
00115 #include <PsnMomeFifo.h>
00116 #endif
00117 
00118 template <typename Type> 
00119 int PsnAbstractFifo<Type>::getMaximumNumberOfValues() const {
00120    return _fifoSize ;
00121 }
00122 
00123 template <typename Type> 
00124 PsnAbstractFifo<Type>::PsnAbstractFifo (const int taille) : _fifoSize ( taille ) {
00125 
00126 }
00127 
00128 template <typename Type>
00129 PsnAbstractFifo<Type>::~PsnAbstractFifo ( ) {
00130 
00131 } 
00132 
00133 template <typename Type>
00134 void PsnAbstractFifo<Type>::printDebuggingInformation() const {
00135    cerr<< "Capacity of fifo : "<<_fifoSize<<endl;
00136 }
00137 
00138 //------------------------------------------------------------------------
00139 
00140 template <typename Type>
00141 void PsnAbstractFifo<Type>::extract (istream & in) {
00142    PsDate dateDerniereVal;
00143    Type data;
00144    in >> dateDerniereVal >> data ;
00145    set(data, dateDerniereVal);
00146 }
00147 
00148 
00149    
00150 template <typename Type>
00151 void PsnAbstractFifo<Type>::insertInStream (ostream & out) const 
00152 {
00153    out << getPreceedingDate (0) << " "<<getPreceedingValue (0) << " ";
00154 }
00155 
00156 
00157 template <typename Type>
00158 void PsnAbstractFifo<Type>::unpack (PsIncomingSynchronisationMessage & in) 
00159 {
00160    Type & receivedValue ( getNextPlaceHolder() ) ;
00161    receivedValue.unpack( in ) ;
00162    setInPlace( receivedValue, in.getMessageDate() );
00163 }
00164    
00165 template <typename Type>
00166 void PsnAbstractFifo<Type>::unpackAllValues (PsIncomingSynchronisationMessage & in) 
00167 {
00168    Type & receivedValue ( getNextPlaceHolder() ) ;
00169    PsDate dateOfReceivedValue ;
00170    dateOfReceivedValue.unpack ( in ) ;
00171    receivedValue.unpack( in ) ;
00172    setInPlace( receivedValue , dateOfReceivedValue );
00173 }
00174    
00175 template <typename Type>
00176 void PsnAbstractFifo<Type>::pack (PsOutgoingSynchronisationMessage & out ) const 
00177 {
00178    getPreceedingValue (0).pack (out) ;
00179 }
00180 
00181 template <typename Type>
00182 void PsnAbstractFifo<Type>::packAllValues (PsOutgoingSynchronisationMessage & out ) const 
00183 {
00184    // implement in a minimal fashion
00185    getPreceedingDate (0).pack(out) ;
00186    getPreceedingValue (0).pack (out) ;
00187 }
00188 
00189 #endif
00190 
00191 

logo OpenMask

Documentation generated on Mon Nov 25 15:25:00 2002

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