File indexing completed on 2024-05-19 04:25:10

0001 #ifndef KISROLLINGSUMACCUMULATORWRAPPER_H
0002 #define KISROLLINGSUMACCUMULATORWRAPPER_H
0003 
0004 #include <QtGlobal>
0005 #include <QScopedPointer>
0006 #include "kritaglobal_export.h"
0007 
0008 /**
0009  * @brief A simple wrapper class that hides boost includes from QtCreator preventing it
0010  * from crashing when one adds boost's accumulator into a file
0011  */
0012 
0013 class KRITAGLOBAL_EXPORT KisRollingSumAccumulatorWrapper
0014 {
0015 public:
0016     /**
0017      * Create a rolling sum and count accumulator with window \p windowSize
0018      */
0019     KisRollingSumAccumulatorWrapper(int windowSize);
0020     ~KisRollingSumAccumulatorWrapper();
0021 
0022     /**
0023      * Add \p value to a set of numbers
0024      */
0025     void operator()(qreal value);
0026 
0027     /**
0028      * Get rolling sum of the numbers passed to the operator
0029      */
0030     qreal rollingSum() const;
0031 
0032 
0033     /**
0034      * Get the number of elements in the rolling window
0035      */
0036     int rollingCount() const;
0037 
0038     /**
0039      * Reset  accumulator and any stored value
0040      */
0041     void reset(int windowSize);
0042 
0043 private:
0044     struct Private;
0045     const QScopedPointer<Private> m_d;
0046 };
0047 
0048 #endif // KISROLLINGSUMACCUMULATORWRAPPER_H