CMS 3D CMS Logo

AbsVisitor.h
Go to the documentation of this file.
1 #ifndef NPSTAT_ABSVISITOR_HH_
2 #define NPSTAT_ABSVISITOR_HH_
3 
14 namespace npstat {
18  template <typename Input, typename Result>
19  struct AbsVisitor {
20  inline virtual ~AbsVisitor() {}
21 
23  virtual void clear() = 0;
24 
26  virtual void process(const Input& value) = 0;
27 
29  virtual Result result() = 0;
30  };
31 
37  template <typename Input>
38  class VisitCounter : public AbsVisitor<Input, unsigned long> {
39  public:
40  inline VisitCounter() : counter_(0UL) {}
41  inline virtual ~VisitCounter() {}
42 
43  inline void clear() { counter_ = 0UL; }
44  inline void process(const Input&) { ++counter_; }
45  inline unsigned long result() { return counter_; }
46 
47  private:
48  unsigned long counter_;
49  };
50 } // namespace npstat
51 
52 #endif // ABSVISITOR_HH_
virtual ~AbsVisitor()
Definition: AbsVisitor.h:20
virtual void clear()=0
virtual void process(const Input &value)=0
virtual Result result()=0
void process(const Input &)
Definition: AbsVisitor.h:44
unsigned long counter_
Definition: AbsVisitor.h:48
Definition: value.py:1
unsigned long result()
Definition: AbsVisitor.h:45
virtual ~VisitCounter()
Definition: AbsVisitor.h:41