data() can not be const
[senf.git] / senf / Utils / StatisticAccumulator.hh
index 6c08c41..0293e5f 100644 (file)
 #include <boost/cstdint.hpp>
 ///////////////////////////////hh.p////////////////////////////////////////
 namespace senf {
-    /** \brief Accumulate measurement values
-
-        The accumulator mainly do the prelimenary work for the senf::Statistic class.
-        It accumulates certain values with in an interval to be used by senf::Statistics
-
-        \li the senf::Statistics class
-        \li statistics sources
-
-        This class provides the average, standard deviation, min, max values over one
-        interval, means until clear() is called. It rather directly calculates the results
-        then collection all single values provided by calling accumulate().
-        \see senf::Statistics to process accumulated values
-        \ingroup senf_statistics
-        */
 
+     struct StatisticsData
+     {
+         float min;
+         float max;
+         float avg;
+         float stddev;
+         boost::uint32_t count;
+     };
+
+     /** \brief Accumulate measurement values
+
+         The accumulator mainly do the prelimenary work for the senf::Statistic class.
+         It accumulates certain values with in an interval to be used by senf::Statistics
+
+         \li the senf::Statistics class
+         \li statistics sources
+
+         This class provides the average, standard deviation, min, max values over one
+         interval, means until clear() is called. It rather directly calculates the results
+         then collection all single values provided by calling accumulate().
+         \see senf::Statistics to process accumulated values
+         \ingroup senf_statistics
+      */
     template <class T>
     class StatisticAccumulator
     {
     public:
-        StatisticAccumulator( T defaultvalue = 0);
+        StatisticAccumulator();
 //        virtual ~StatisticAccumulator();
 
         void clear();
         ///< Reset accumulated values.
-        /**< This member reset all avg/min/max values to the given \a
-             defaultvalue and the count to zero. */
+        /**< This member reset all values. */
         void accumulate(T value);
         ///< Gather value to be accumulated.
         /**< This method accumulate a value.
@@ -81,9 +89,11 @@ namespace senf {
         boost::uint32_t count() const;
         ///< Returns count of accumulated values.
         /**< This method returns count of accumulated values of the current accumulation.*/
+        void data( StatisticsData & data_);
+        ///< Returns the accumulated data as a tuple
+        /**< This method returns the accumulated information as a tuple.*/  
 
     private:
-        T defaultvalue_;
         T sum_squared_;
         T sum_;
         T min_;
@@ -98,7 +108,6 @@ namespace senf {
     typedef StatisticAccumulator<int> StatisticAccumulatorInt;
     typedef StatisticAccumulator<float> StatisticAccumulatorFloat;
 
-
 }
 ///////////////////////////////hh.e////////////////////////////////////////
 //#include "StatisticAccumulator.cci"