CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/JetMETCorrections/InterpolationTables/interface/AbsVisitor.h

Go to the documentation of this file.
00001 #ifndef NPSTAT_ABSVISITOR_HH_
00002 #define NPSTAT_ABSVISITOR_HH_
00003 
00014 namespace npstat {
00018     template <typename Input, typename Result>
00019     struct AbsVisitor
00020     {
00021         inline virtual ~AbsVisitor() {}
00022 
00024         virtual void clear() = 0;
00025 
00027         virtual void process(const Input& value) = 0;
00028 
00030         virtual Result result() = 0;
00031     };
00032 
00038     template <typename Input>
00039     class VisitCounter : public AbsVisitor<Input,unsigned long>
00040     {
00041     public:
00042         inline VisitCounter() : counter_(0UL) {}
00043 
00044         inline void clear() {counter_ = 0UL;}
00045         inline void process(const Input&) {++counter_;}
00046         inline unsigned long result() {return counter_;}
00047 
00048     private:
00049         unsigned long counter_;
00050     };
00051 }
00052 
00053 #endif // ABSVISITOR_HH_
00054