4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief StatisticAccumulator public header */
26 #ifndef HH_SENF_Utils_StatisticAccumulator_
27 #define HH_SENF_Utils_StatisticAccumulator_ 1
31 #include <boost/cstdint.hpp>
32 ///////////////////////////////hh.p////////////////////////////////////////
37 StatisticsData( float min_, float avg_, float max_, float stddev_, boost::uint32_t count_)
38 : min(min_), avg(avg_), max(max_), stddev(stddev_), count(count_){
40 StatisticsData( StatisticsData const & other)
41 : min(other.min), avg(other.avg), max(other.max), stddev(other.stddev), count(other.count){
44 : min(0.0), avg(0.0), max(0.0), stddev(0.0), count(0){
51 boost::uint32_t count;
54 /** \brief Accumulate measurement values
56 The accumulator mainly do the prelimenary work for the senf::Statistic class.
57 It accumulates certain values with in an interval to be used by senf::Statistics
59 \li the senf::Statistics class
60 \li statistics sources
62 This class provides the average, standard deviation, min, max values over one
63 interval, means until clear() is called. It rather directly calculates the results
64 then collection all single values provided by calling accumulate().
65 \see senf::Statistics to process accumulated values
66 \ingroup senf_statistics
69 class StatisticAccumulator
72 StatisticAccumulator();
73 // virtual ~StatisticAccumulator();
76 ///< Reset accumulated values.
77 /**< This member reset all values. */
78 void accumulate(T value);
79 ///< Gather value to be accumulated.
80 /**< This method accumulates a value.
81 \param[in] value to be accumulated value*/
82 void setLastAvg(T value);
83 ///< If no real data was collected, this method specifies the min/avg/max value to be returned.
84 /**< This method specifies the the min/avg/max value to be returned if no real data was colelcted
85 \param[in] value to be returned*/
89 ///< Returns current minimal value.
90 /**< This method returns the minimal value of the current accumulation.*/
92 ///< Returns current maximal value.
93 /**< This method returns the maximal value of the current accumulation.*/
95 ///< Returns average value.
96 /**< This method returns the average value of the current accumulation.*/
97 float last_avg() const;
98 ///< Returns former average value.
99 /**< This method returns the average value of the former accumulation period.*/
100 float stddev() const;
101 ///< Returns standard deviation value.
102 /**< This method returns the standard deviation value of the current accumulation.*/
103 boost::uint32_t count() const;
104 ///< Returns count of accumulated values.
105 /**< This method returns count of accumulated values of the current accumulation.*/
106 void data( StatisticsData & data_) const;
107 ///< Returns the accumulated data as a tuple
108 /**< This method returns the accumulated information as a tuple.*/
116 boost::uint32_t count_;
122 typedef StatisticAccumulator<int> StatisticAccumulatorInt;
123 typedef StatisticAccumulator<float> StatisticAccumulatorFloat;
126 ///////////////////////////////hh.e////////////////////////////////////////
127 //#include "StatisticAccumulator.cci"
128 #include "StatisticAccumulator.ct"
129 #include "StatisticAccumulator.cti"