OMKAbstractFifo.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 OMKAbstractFifoHEADER
00019 #define OMKAbstractFifoHEADER
00020 
00021 #include "OMKTracer.h"
00022 #include "OMKSimpleTypeT.h"
00023 
00024 namespace OMK
00025 {
00029 template <typename T>
00030 class AbstractFifo : public Flowable
00031 {
00032   
00033 public :
00035    AbstractFifo (const int taille) ;
00036 
00037 
00039    virtual ~AbstractFifo () ;
00040 
00041 
00043    virtual int getMaximumNumberOfValues() const ;
00044 
00045 
00048    virtual unsigned int getNumberOfPresentValues( int lookingFor = -1 ) const = 0 ;
00049 
00050 
00054    virtual const T& getPreceedingValue (const unsigned int index) const = 0 ;
00055 
00056 
00060    virtual const Date & getPreceedingDate(const unsigned int indice) const = 0 ;
00061    
00062 
00064    virtual void set (const T& val, const Date & date) = 0 ;
00065 
00066 
00068    virtual void setInPlace ( const T& val, const Date & date) = 0 ;
00069 
00070 
00072    virtual T& getNextPlaceHolder() = 0 ;
00073 
00074 
00076    virtual void clear () = 0 ;
00077 
00078 
00080    virtual void printDebuggingInformation(void) const ;
00081 
00082 
00085    virtual void extract (std::istream & = std::cin) ;
00086    
00087 
00090    virtual void insertInStream (std::ostream & = std::cout) const  ;
00091   
00093    virtual void unpack (IncomingSynchronisationMessage &) ;
00094    
00096    virtual void pack (OutgoingSynchronisationMessage &) const ;
00097 
00099    virtual void unpackAllValues (IncomingSynchronisationMessage &) ;
00100    
00102    virtual void packAllValues (OutgoingSynchronisationMessage &) const ;
00103 
00104 protected :
00106    unsigned int _fifoSize ;
00107 
00108 } ; // AbstractFifo
00109 }// namespace OMK
00110 
00111 //because everything is template, #include all the Existing FIFO here. 
00112 
00113 #include <OMKFifo.h>
00114 #include <OMKIncomingSynchronisationMessage.h>
00115 #include <OMKSimpleTypeT.inl>
00116 namespace OMK
00117 {
00118 template <typename T> 
00119 int AbstractFifo<T>::getMaximumNumberOfValues() const {
00120    return _fifoSize ;
00121 }
00122 
00123 template <typename T> 
00124 AbstractFifo<T>::AbstractFifo (const int taille) : _fifoSize ( taille ) {
00125 
00126 }
00127 
00128 template <typename T>
00129 AbstractFifo<T>::~AbstractFifo ( ) {
00130 
00131 } 
00132 
00133 template <typename T>
00134 void AbstractFifo<T>::printDebuggingInformation() const 
00135 {
00136    std::cerr<< "Capacity of fifo : "<<_fifoSize<<std::endl;
00137 }
00138 
00139 //------------------------------------------------------------------------
00140 
00141 template <typename T>
00142 void AbstractFifo<T>::extract (std::istream & in) {
00143    Date dateDerniereVal;
00144    T data;
00145    in >> dateDerniereVal >> data ;
00146    set(data, dateDerniereVal);
00147 }
00148 
00149 
00150    
00151 template <typename T>
00152 void AbstractFifo<T>::insertInStream (std::ostream & out) const 
00153 {
00154    out << getPreceedingDate (0) << " "<<getPreceedingValue (0) << " ";
00155 }
00156 
00157 
00158 template <typename T>
00159 void AbstractFifo<T>::unpack (IncomingSynchronisationMessage & in) 
00160 {
00161    T& receivedValue ( getNextPlaceHolder() ) ;
00162    receivedValue.unpack( in ) ;
00163    setInPlace( receivedValue, in.getMessageDate() );
00164 }
00165    
00166 template <typename T>
00167 void AbstractFifo<T>::unpackAllValues (IncomingSynchronisationMessage & in) 
00168 {
00169    T& receivedValue ( getNextPlaceHolder() ) ;
00170    OMK::Type::SimpleTypeT< Date > dateOfReceivedValue ;
00171    dateOfReceivedValue.unpack ( in ) ;
00172    receivedValue.unpack( in ) ;
00173    setInPlace( receivedValue , dateOfReceivedValue );
00174 }
00175    
00176 template <typename T>
00177 void AbstractFifo<T>::pack (OutgoingSynchronisationMessage & out ) const 
00178 {
00179    getPreceedingValue (0).pack (out) ;
00180 }
00181 
00182 template <typename T>
00183 void AbstractFifo<T>::packAllValues (OutgoingSynchronisationMessage & out ) const 
00184 {
00185    // implement in a minimal fashion
00186   OMK::Type::SimpleTypeT< Date >( getPreceedingDate( 0 ) ).pack(out) ;
00187    getPreceedingValue (0).pack (out) ;
00188 }
00189 } // namespace OMK
00190 #endif
00191 
00192 

logo OpenMask

Documentation generated on Mon Jun 9 11:45:55 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007