00001 #ifndef Filter_H
00002 #define Filter_H 1
00003
00016 template<class Filtered>
00017 class Filter
00018 {
00019 public:
00020
00021 Filter();
00022 virtual ~Filter();
00023
00024
00025 virtual bool accept(const Filtered *filtered) const=0;
00026 virtual void reset();
00027 virtual void unset(){;}
00028
00029 bool filter(const Filtered * filtered);
00030 int getAnalyzedCount();
00031 int getAcceptedCount();
00032
00033 protected:
00034
00035 int _analyzedCount;
00036 int _acceptedCount;
00037
00038 };
00039
00040
00041 template<class Filtered>
00042 Filter<Filtered>::Filter()
00043 : _analyzedCount(0),
00044 _acceptedCount(0)
00045 {}
00046
00047 template<class Filtered>
00048 Filter<Filtered>::~Filter()
00049 {}
00050
00051 template<class Filtered>
00052 inline bool Filter<Filtered>::filter(const Filtered *filtered)
00053 {
00054 _analyzedCount++;
00055 bool acc = accept(filtered);
00056 if (acc) _acceptedCount++;
00057 return acc;
00058 }
00059
00060 template<class Filtered>
00061 inline void Filter<Filtered>::reset()
00062 {
00063 _analyzedCount = 0;
00064 _acceptedCount = 0;
00065 }
00066
00067 template<class Filtered>
00068 int Filter<Filtered>::getAnalyzedCount()
00069 {
00070 return _analyzedCount;
00071 }
00072
00073 template<class Filtered>
00074 int Filter<Filtered>::getAcceptedCount()
00075 {
00076 return _acceptedCount;
00077 }
00078
00079 #endif
00080