Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/SlidingAverageValue.h

Go to the documentation of this file.
00001 /**
00002  * @file SlidingAverageValue.h
00003  *
00004  * Declaration of class SlidingAverageValue
00005  *
00006  * @author Jochen Kerdels
00007  */
00008 
00009 #ifndef __SlidingAverageValue_h_
00010 #define __SlidingAverageValue_h_
00011 
00012 static const int maxSlidingRange = 25;
00013 
00014 /**
00015  * @class SlidingAverageValue
00016  *
00017  * class for cyclic buffering of the last "size" values of Type int
00018  * output via = operator is the average of the last "size" values
00019  * input a new value also via = operator
00020  * ATTENTION: the "current-index" is driven by the trigger, so
00021  * the given average is an average over the last "size" trigger-events !
00022  */
00023 class SlidingAverageValue
00024 {
00025   public:
00026     /** Constructor */
00027     SlidingAverageValue();
00028 
00029     /**
00030      * resets the SlidingAverageValue 
00031      * \param aSize size of the sliding range
00032      */
00033     void reset(int aSize);
00034     
00035     /**
00036      * triggers to the next index
00037      */
00038     void trigger ();
00039 
00040     /**
00041      * adds an entry to the buffer
00042      * \param value value to be added
00043      */
00044     void add (int value);
00045 
00046     int getAverage();
00047 
00048     int getLastValue();
00049 
00050     SlidingAverageValue& operator=(int aInt);
00051 
00052     SlidingAverageValue& operator-=(int aInt);
00053 
00054     SlidingAverageValue& operator+=(int aInt);
00055 
00056     operator int() { return getAverage(); };
00057 
00058   private:
00059     int minIdx;
00060     int maxIdx;
00061     int numOfEntries;
00062     int size;
00063     int buffer[maxSlidingRange];
00064     int timeOfLastAdd;
00065     int sum;
00066     int trig;
00067 };
00068 
00069 
00070 #endif // __SlidingAverageValue_h_
00071 
00072 /*
00073  * Change log :
00074  * 
00075  * $Log: SlidingAverageValue.h,v $
00076  * Revision 1.1.1.1  2004/05/22 17:35:55  cvsadm
00077  * created new repository GT2004_WM
00078  *
00079  * Revision 1.1  2004/04/08 16:04:06  wachter
00080  * GT04 checkin of Microsoft-Hellounds
00081  *
00082  * Revision 1.1  2004/03/21 04:36:07  pg_joke
00083  * added slidingAverage to OptionRatings,
00084  * added ratingBoost (Hysteresis) to OptionRatings
00085  *
00086  *
00087  */

Generated on Thu Sep 23 19:57:41 2004 for GT2004 by doxygen 1.3.6