ImageCache< T > Class Template Reference

base class for image caches that do computations on the fly More...

#include <Image/ImageCache.H>

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

List of all members.

Public Member Functions

 ImageCache (uint maxSize=0)
 Constructor.
virtual ~ImageCache ()
 Destructor.
virtual void setMaxSize (const uint maxSize)
 Set maximum number of images in the cache.
virtual uint getMaxSize () const
 Get maximum number of images in the cache.
virtual void push_back (const Image< T > &img)
 add image to cache - if the cache gets to big, old images are popped off
virtual Image< T > pop_front ()
 pop the front Image (oldest) off the cache and return it
virtual const Image< T > & back () const
 access the last Image (newest) in the queue
virtual const Image< T > & front () const
 access the first Image (oldest) in the queue
virtual const Image< T > & getImage (const uint lev) const
 Get image from a given level.
virtual const Image< T > & operator[] (const uint lev) const
 Get image from a given level (shorthand for getImage()).
virtual uint size () const
 return the current size of the cache
virtual bool empty () const
 true if the cache contains no elements
virtual void clear ()
 clear the cache, preserving its maxSize

Protected Member Functions

virtual void popOffOld ()
 checks whether the cache has become too big and removes old entries
virtual void doWhenAdd (const Image< T > &img)
 called when an image is added - override in your derived classes!
virtual void doWhenRemove (const Image< T > &img)
 called when an image is removed - override in your derived classes

Protected Attributes

uint itsMaxSize
 the maximum size of images to be stored
std::deque< Image< T > > itsCache
 the cache of the images

Detailed Description

template<class T>
class ImageCache< T >

base class for image caches that do computations on the fly

This base class has no op doWhenAdd and doWhenRemove functions that should be overridden in classes derived from this one.

Definition at line 52 of file ImageCache.H.


Constructor & Destructor Documentation

template<class T >
ImageCache< T >::ImageCache ( uint  maxSize = 0  )  [inline]

Constructor.

Parameters:
maxSize the maximum size of the cache. If this size is exceeded, images are popped off the front of the cache and disregarded for the computation of the mean. If maxSize = 0, the cache is not limited.

Definition at line 50 of file ImageCache.C.

template<class T >
ImageCache< T >::~ImageCache (  )  [inline, virtual]

Destructor.

Definition at line 56 of file ImageCache.C.


Member Function Documentation

template<class T >
const Image< T > & ImageCache< T >::back (  )  const [inline, virtual]

access the last Image (newest) in the queue

Definition at line 109 of file ImageCache.C.

References ASSERT, and ImageCache< T >::itsCache.

Referenced by TcorrChannel::getOutput(), and FOEestimator::updateFOE().

template<class T >
void ImageCache< T >::clear (  )  [inline, virtual]

clear the cache, preserving its maxSize

Definition at line 148 of file ImageCache.C.

References ImageCache< T >::pop_front(), and ImageCache< T >::size().

Referenced by TaskRelevanceMapKillN::reset1().

template<class T>
void ImageCache< T >::doWhenAdd ( const Image< T > &  img  )  [inline, protected, virtual]

called when an image is added - override in your derived classes!

in ImageCache, this function is no op

Reimplemented in ImageCacheAvg< T >, ImageCacheMinMax< T >, ImageCacheAvg< float >, ImageCacheAvg< byte >, and ImageCacheMinMax< float >.

Definition at line 158 of file ImageCache.C.

Referenced by ImageCache< T >::push_back().

template<class T>
void ImageCache< T >::doWhenRemove ( const Image< T > &  img  )  [inline, protected, virtual]

called when an image is removed - override in your derived classes

in ImageCache, this function is no op

Reimplemented in ImageCacheAvg< T >, ImageCacheMinMax< T >, ImageCacheAvg< float >, ImageCacheAvg< byte >, and ImageCacheMinMax< float >.

Definition at line 163 of file ImageCache.C.

Referenced by ImageCache< T >::pop_front().

template<class T >
bool ImageCache< T >::empty (  )  const [inline, virtual]

true if the cache contains no elements

Definition at line 143 of file ImageCache.C.

References ImageCache< T >::itsCache.

template<class T >
const Image< T > & ImageCache< T >::front (  )  const [inline, virtual]

access the first Image (oldest) in the queue

Definition at line 117 of file ImageCache.C.

References ASSERT, and ImageCache< T >::itsCache.

Referenced by TcorrChannel::getOutput().

template<class T >
const Image< T > & ImageCache< T >::getImage ( const uint  lev  )  const [inline, virtual]

Get image from a given level.

Definition at line 125 of file ImageCache.C.

References ASSERT, and ImageCache< T >::itsCache.

Referenced by ImageCache< T >::operator[]().

template<class T >
uint ImageCache< T >::getMaxSize (  )  const [inline, virtual]

Get maximum number of images in the cache.

Definition at line 70 of file ImageCache.C.

References ImageCache< T >::itsMaxSize.

Referenced by TcorrChannel::doInput(), TcorrChannel::getOutput(), and TcorrChannel::outputAvailable().

template<class T >
const Image< T > & ImageCache< T >::operator[] ( const uint  lev  )  const [inline, virtual]

Get image from a given level (shorthand for getImage()).

Definition at line 133 of file ImageCache.C.

References ImageCache< T >::getImage().

template<class T >
Image< T > ImageCache< T >::pop_front (  )  [inline, virtual]

pop the front Image (oldest) off the cache and return it

Definition at line 98 of file ImageCache.C.

References ASSERT, ImageCache< T >::doWhenRemove(), and ImageCache< T >::itsCache.

Referenced by ImageCache< T >::clear(), and ImageCache< T >::popOffOld().

template<class T >
void ImageCache< T >::popOffOld (  )  [inline, protected, virtual]

checks whether the cache has become too big and removes old entries

Definition at line 85 of file ImageCache.C.

References ImageCache< T >::itsCache, ImageCache< T >::itsMaxSize, and ImageCache< T >::pop_front().

Referenced by ImageCache< T >::push_back(), and ImageCache< T >::setMaxSize().

template<class T>
void ImageCache< T >::push_back ( const Image< T > &  img  )  [inline, virtual]
template<class T >
void ImageCache< T >::setMaxSize ( const uint  maxSize  )  [inline, virtual]
template<class T >
uint ImageCache< T >::size (  )  const [inline, virtual]

return the current size of the cache

This may be smaller than the maximum size specified at construction or with setMaxSize(), if the cache is not full yet.

Definition at line 138 of file ImageCache.C.

References ImageCache< T >::itsCache.

Referenced by ImageCache< T >::clear(), TcorrChannel::getOutput(), main(), TcorrChannel::outputAvailable(), and FOEestimator::updateFOE().


Member Data Documentation

template<class T>
std::deque< Image<T> > ImageCache< T >::itsCache [protected]
template<class T>
uint ImageCache< T >::itsMaxSize [protected]

the maximum size of images to be stored

Definition at line 114 of file ImageCache.H.

Referenced by ImageCache< T >::getMaxSize(), ImageCache< T >::popOffOld(), and ImageCache< T >::setMaxSize().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:22:18 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3