ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/utils/Accumulator.hpp
(Generate patch)

Comparing trunk/src/utils/Accumulator.hpp (file contents):
Revision 1782 by gezelter, Wed Aug 22 02:28:28 2012 UTC vs.
Revision 1791 by gezelter, Fri Aug 31 16:48:50 2012 UTC

# Line 49 | Line 49 | namespace OpenMD {
49  
50   namespace OpenMD {
51  
52 +
53 +  class BaseAccumulator {
54 +  public:
55 +    virtual void clear() = 0;
56 +    /**
57 +     * get the number of accumulated values
58 +     */
59 +    virtual size_t count()  {
60 +      return Count_;
61 +    }
62 +  protected:
63 +    size_t Count_;
64 +
65 +  };  
66 +
67 +
68 +
69    /**
70     * Basic Accumulator class for numbers.
71 <   */
72 <  
56 <  class Accumulator {    
71 >   */  
72 >  class Accumulator : public BaseAccumulator {    
73  
74      typedef RealType ElementType;
75      typedef RealType ResultType;
76  
77    public:
78      
79 <    Accumulator() {
79 >    Accumulator() : BaseAccumulator() {
80        this->clear();
81      }
82  
# Line 91 | Line 107 | namespace OpenMD {
107        Val_   = 0;
108      }
109      
94    /**
95     * get the number of accumulated values
96     */
97    size_t count()  {
98      return Count_;
99    }
110  
111      /**
112       * return the most recently added value
# Line 153 | Line 163 | namespace OpenMD {
163        return;
164      }
165  
156  protected:
157    size_t Count_;
166    private:
167      ElementType Val_;
168      ResultType Avg_;
# Line 163 | Line 171 | namespace OpenMD {
171      ElementType Max_;
172    };
173  
174 <  class VectorAccumulator : public Accumulator {
174 >  class VectorAccumulator : public BaseAccumulator {
175      
176      typedef Vector3d ElementType;
177      typedef Vector3d ResultType;
178      
179    public:
180 <    VectorAccumulator() : Accumulator() {
180 >    VectorAccumulator() : BaseAccumulator() {
181        this->clear();
182      }
183  
# Line 311 | Line 319 | namespace OpenMD {
319  
320    };
321  
322 <  class MatrixAccumulator : public Accumulator {
322 >  class MatrixAccumulator : public BaseAccumulator {
323      
324      typedef Mat3x3d ElementType;
325      typedef Mat3x3d ResultType;
326      
327    public:
328 <    MatrixAccumulator() : Accumulator() {
328 >    MatrixAccumulator() : BaseAccumulator() {
329        this->clear();
330      }
331  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines