OMK::AbstractFifo< T > Class Template Reference

Abstract Fifo used to store attribute history information For thread safety reasons, this class should ensure that multiple reads and one write can be done in concurrent fashion and with coherant results. More...

#include <OMKAbstractFifo.h>

Inheritance diagram for OMK::AbstractFifo< T >:

Inheritance graph
[legend]
Collaboration diagram for OMK::AbstractFifo< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AbstractFifo (const int taille)
 constructor
virtual ~AbstractFifo ()
 destructor
virtual int getMaximumNumberOfValues () const
 get the size of the fifo
virtual unsigned int getNumberOfPresentValues (int lookingFor=-1) const=0
 get the number of values in the fifo
virtual const T & getPreceedingValue (const unsigned int index) const=0
 get a value before the current value
virtual const DategetPreceedingDate (const unsigned int indice) const=0
 get the date associated to a value before the current value
virtual void set (const T &val, const Date &date)=0
 add a value to the fifo
virtual void setInPlace (const T &val, const Date &date)=0
 make an allready copied value available for reading
virtual T & 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 (void) const
 printDebuggingInformation print any usefull debugging information
virtual void extract (std::istream &=std::cin)
 extract from an input stream
virtual void insertInStream (std::ostream &=std::cout) const
 insert in a output stream
virtual void unpack (IncomingSynchronisationMessage &)
 unpack an update from a message (suppose the value's timestamp is the message's timestamp
virtual void pack (OutgoingSynchronisationMessage &) const
 pack in an update message
virtual void unpackAllValues (IncomingSynchronisationMessage &)
 unpack a complete (implemented in a minimal fashion) from a message
virtual void packAllValues (OutgoingSynchronisationMessage &) const
 pack a complete message

Protected Attributes

unsigned int _fifoSize
 Number of values that can be contained in the FIFO.

Detailed Description

template<typename T>
class OMK::AbstractFifo< T >

Abstract Fifo used to store attribute history information For thread safety reasons, this class should ensure that multiple reads and one write can be done in concurrent fashion and with coherant results.

Definition at line 30 of file OMKAbstractFifo.h.


Constructor & Destructor Documentation

template<typename T>
OMK::AbstractFifo< T >::AbstractFifo ( const int  taille  ) 

constructor

Definition at line 124 of file OMKAbstractFifo.h.

00124                                                : _fifoSize ( taille ) {
00125 
00126 }

template<typename T>
OMK::AbstractFifo< T >::~AbstractFifo (  )  [virtual]

destructor

Definition at line 129 of file OMKAbstractFifo.h.

00129                                  {
00130 
00131 } 


Member Function Documentation

template<typename T>
int OMK::AbstractFifo< T >::getMaximumNumberOfValues (  )  const [virtual]

get the size of the fifo

Definition at line 119 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::_fifoSize.

00119                                                     {
00120    return _fifoSize ;
00121 }

template<typename T>
virtual unsigned int OMK::AbstractFifo< T >::getNumberOfPresentValues ( int  lookingFor = -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

Implemented in OMK::Fifo< T >.

template<typename T>
virtual const T& OMK::AbstractFifo< T >::getPreceedingValue ( const unsigned int  index  )  const [pure virtual]

get a value before the current value

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

Implemented in OMK::Fifo< T >.

Referenced by OMK::AbstractFifo< T >::insertInStream(), OMK::AbstractFifo< T >::pack(), and OMK::AbstractFifo< T >::packAllValues().

template<typename T>
virtual const Date& OMK::AbstractFifo< T >::getPreceedingDate ( const unsigned int  indice  )  const [pure 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...

Implemented in OMK::Fifo< T >.

Referenced by OMK::AbstractFifo< T >::insertInStream(), and OMK::AbstractFifo< T >::packAllValues().

template<typename T>
virtual void OMK::AbstractFifo< T >::set ( const T &  val,
const Date date 
) [pure virtual]

add a value to the fifo

Implemented in OMK::Fifo< T >.

Referenced by OMK::AbstractFifo< T >::extract().

template<typename T>
virtual void OMK::AbstractFifo< T >::setInPlace ( const T &  val,
const Date date 
) [pure virtual]

make an allready copied value available for reading

Implemented in OMK::Fifo< T >.

Referenced by OMK::AbstractFifo< T >::unpack(), and OMK::AbstractFifo< T >::unpackAllValues().

template<typename T>
virtual T& OMK::AbstractFifo< T >::getNextPlaceHolder (  )  [pure virtual]

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

Implemented in OMK::Fifo< T >.

Referenced by OMK::AbstractFifo< T >::unpack(), and OMK::AbstractFifo< T >::unpackAllValues().

template<typename T>
virtual void OMK::AbstractFifo< T >::clear (  )  [pure virtual]

clear the fifo

Implemented in OMK::Fifo< T >.

template<typename T>
void OMK::AbstractFifo< T >::printDebuggingInformation ( void   )  const [virtual]

printDebuggingInformation print any usefull debugging information

Reimplemented in OMK::Fifo< T >.

Definition at line 134 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::_fifoSize.

00135 {
00136    std::cerr<< "Capacity of fifo : "<<_fifoSize<<std::endl;
00137 }

template<typename T>
void OMK::AbstractFifo< T >::extract ( std::istream &  = std::cin  )  [virtual]

extract from an input stream

Implements OMK::Flowable.

Definition at line 142 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::set().

00142                                               {
00143    Date dateDerniereVal;
00144    T data;
00145    in >> dateDerniereVal >> data ;
00146    set(data, dateDerniereVal);
00147 }

template<typename T>
void OMK::AbstractFifo< T >::insertInStream ( std::ostream &  = std::cout  )  const [virtual]

insert in a output stream

Implements OMK::Flowable.

Definition at line 152 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::getPreceedingDate(), and OMK::AbstractFifo< T >::getPreceedingValue().

00153 {
00154    out << getPreceedingDate (0) << " "<<getPreceedingValue (0) << " ";
00155 }

template<typename T>
void OMK::AbstractFifo< T >::unpack ( IncomingSynchronisationMessage  )  [virtual]

unpack an update from a message (suppose the value's timestamp is the message's timestamp

Reimplemented from OMK::Flowable.

Definition at line 159 of file OMKAbstractFifo.h.

References OMK::IncomingSynchronisationMessage::getMessageDate(), OMK::AbstractFifo< T >::getNextPlaceHolder(), and OMK::AbstractFifo< T >::setInPlace().

00160 {
00161    T& receivedValue ( getNextPlaceHolder() ) ;
00162    receivedValue.unpack( in ) ;
00163    setInPlace( receivedValue, in.getMessageDate() );
00164 }

template<typename T>
void OMK::AbstractFifo< T >::pack ( OutgoingSynchronisationMessage  )  const [virtual]

pack in an update message

Reimplemented from OMK::Flowable.

Definition at line 177 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::getPreceedingValue().

Referenced by OMK::AbstractFifo< T >::packAllValues().

00178 {
00179    getPreceedingValue (0).pack (out) ;
00180 }

template<typename T>
void OMK::AbstractFifo< T >::unpackAllValues ( IncomingSynchronisationMessage  )  [virtual]

unpack a complete (implemented in a minimal fashion) from a message

Definition at line 167 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::getNextPlaceHolder(), OMK::AbstractFifo< T >::setInPlace(), and OMK::Type::SimpleTypeT< T >::unpack().

00168 {
00169    T& receivedValue ( getNextPlaceHolder() ) ;
00170    OMK::Type::SimpleTypeT< Date > dateOfReceivedValue ;
00171    dateOfReceivedValue.unpack ( in ) ;
00172    receivedValue.unpack( in ) ;
00173    setInPlace( receivedValue , dateOfReceivedValue );
00174 }

template<typename T>
void OMK::AbstractFifo< T >::packAllValues ( OutgoingSynchronisationMessage  )  const [virtual]

pack a complete message

Definition at line 183 of file OMKAbstractFifo.h.

References OMK::AbstractFifo< T >::getPreceedingDate(), OMK::AbstractFifo< T >::getPreceedingValue(), and OMK::AbstractFifo< T >::pack().

00184 {
00185    // implement in a minimal fashion
00186   OMK::Type::SimpleTypeT< Date >( getPreceedingDate( 0 ) ).pack(out) ;
00187    getPreceedingValue (0).pack (out) ;
00188 }


Member Data Documentation

template<typename T>
unsigned int OMK::AbstractFifo< T >::_fifoSize [protected]

Number of values that can be contained in the FIFO.

Definition at line 106 of file OMKAbstractFifo.h.

Referenced by OMK::AbstractFifo< T >::getMaximumNumberOfValues(), OMK::Fifo< T >::getNextPlaceHolder(), OMK::Fifo< T >::getNumberOfPresentValues(), OMK::Fifo< T >::getPreceedingDate(), OMK::Fifo< T >::getPreceedingValue(), OMK::AbstractFifo< T >::printDebuggingInformation(), OMK::Fifo< T >::set(), and OMK::Fifo< T >::setInPlace().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:02 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007