Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

VxFrmProcRep.h

00001 /*
00002  *
00003  *  Copyright (c) 2001, TNO TPD, The Netherlands.
00004  *  All rights reserved. No part of this software may be handed to or used by persons 
00005  *  or organisation outside Kenniscentrum Watergraafsmeer (UvA-ISIS, TNO TPD) without 
00006  *  the written permission of TNO TPD.
00007  *
00008  *  Author(s):
00009  *      Jan Baan (baan@tpd.tno.nl)
00010  *
00011  * 
00012  */
00013 
00014 #ifndef VxFrmProcRep_h
00015 #define VxFrmProcRep_h
00016 
00017 
00018 #include "HxString.h"
00019 #include "VxValue.h"
00020 #include <map>
00021 #include <list>
00022 
00023 template<class T>
00024 class VxFrmProcRep{
00025 public:
00027                     VxFrmProcRep(int size = 20);
00028 
00030     void            setSize(int size);
00031 
00033     bool            exist(int frameNr) const;
00034 
00036     T               get(int frameNr);
00037 
00039     void            push(int frameNr, const T& val);
00040 
00041 private:
00042     int                 _size;
00043     std::map<int,T>     _data;
00044     std::list<int>      _frameList;
00045 
00046 };
00047 
00048 template<class T>
00049 VxFrmProcRep<T>::VxFrmProcRep(int size): _size(size) {
00050 }
00051 
00052 template<class T>
00053 inline void
00054 VxFrmProcRep<T>::setSize(int size){
00055     _size = size;
00056 };
00057 
00058 
00059 template<class T>
00060 inline bool 
00061 VxFrmProcRep<T>::exist(int frameNr) const {
00062     if(_size==0) {
00063         return false;
00064     }
00065     return !(_data.find(frameNr)==_data.end());
00066 };
00067 
00068 template<class T>
00069 inline T
00070 VxFrmProcRep<T>::get(int frameNr) {
00071     return _data[frameNr];
00072 }
00073 
00074 
00075 template<class T>
00076 void 
00077 VxFrmProcRep<T>::push(int frameNr, const T& val) {
00078     if(_size==0) {
00079         return;
00080     }
00081 
00082     _data[frameNr] = val;
00083     _frameList.push_back(frameNr);
00084 
00085     _frameList.sort();
00086     while(_frameList.size()>=_size){
00087         _data.erase(_frameList.front());
00088         _frameList.pop_front();
00089     }
00090 
00091 }
00092 
00093 #endif

Generated on Tue Feb 3 14:18:45 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001