4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
28 \brief StatisticAccumulator public header */
30 #ifndef HH_SENF_Utils_StatisticAccumulator_
31 #define HH_SENF_Utils_StatisticAccumulator_ 1
35 #include <boost/cstdint.hpp>
36 ///////////////////////////////hh.p////////////////////////////////////////
41 StatisticsData( float min_, float avg_, float max_, float stddev_, boost::uint32_t count_)
42 : min(min_), avg(avg_), max(max_), stddev(stddev_), count(count_){
44 StatisticsData( StatisticsData const & other)
45 : min(other.min), avg(other.avg), max(other.max), stddev(other.stddev), count(other.count){
48 : min(0.0), avg(0.0), max(0.0), stddev(0.0), count(0){
55 boost::uint32_t count;
58 /** \brief Accumulate measurement values
60 The accumulator mainly do the prelimenary work for the senf::Statistic class.
61 It accumulates certain values with in an interval to be used by senf::Statistics
63 \li the senf::Statistics class
64 \li statistics sources
66 This class provides the average, standard deviation, min, max values over one
67 interval, means until clear() is called. It rather directly calculates the results
68 then collection all single values provided by calling accumulate().
69 \see senf::Statistics to process accumulated values
70 \ingroup senf_statistics
73 class StatisticAccumulator
76 StatisticAccumulator();
77 // virtual ~StatisticAccumulator();
80 ///< Reset accumulated values.
81 /**< This member reset all values. */
82 void accumulate(T value);
83 ///< Gather value to be accumulated.
84 /**< This method accumulates a value.
85 \param[in] value to be accumulated value*/
86 void setLastAvg(T value);
87 ///< If no real data was collected, this method specifies the min/avg/max value to be returned.
88 /**< This method specifies the the min/avg/max value to be returned if no real data was colelcted
89 \param[in] value to be returned*/
93 ///< Returns current minimal value.
94 /**< This method returns the minimal value of the current accumulation.*/
96 ///< Returns current maximal value.
97 /**< This method returns the maximal value of the current accumulation.*/
99 ///< Returns average value.
100 /**< This method returns the average value of the current accumulation.*/
101 float last_avg() const;
102 ///< Returns former average value.
103 /**< This method returns the average value of the former accumulation period.*/
104 float stddev() const;
105 ///< Returns standard deviation value.
106 /**< This method returns the standard deviation value of the current accumulation.*/
107 boost::uint32_t count() const;
108 ///< Returns count of accumulated values.
109 /**< This method returns count of accumulated values of the current accumulation.*/
110 void data( StatisticsData & data_) const;
111 ///< Returns the accumulated data as a tuple
112 /**< This method returns the accumulated information as a tuple.*/
120 boost::uint32_t count_;
126 typedef StatisticAccumulator<int> StatisticAccumulatorInt;
127 typedef StatisticAccumulator<float> StatisticAccumulatorFloat;
130 ///////////////////////////////hh.e////////////////////////////////////////
131 //#include "StatisticAccumulator.cci"
132 #include "StatisticAccumulator.ct"
133 #include "StatisticAccumulator.cti"