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 // Mathias Kretschmer <mtk@berlios.de>
27 // Jens Moedeker <jmo@berlios.de>
30 \brief StatisticAccumulator public header */
32 #ifndef HH_SENF_Utils_StatisticAccumulator_
33 #define HH_SENF_Utils_StatisticAccumulator_ 1
37 #include <boost/cstdint.hpp>
38 #include <senf/Utils/Format.hh>
39 ///////////////////////////////hh.p////////////////////////////////////////
44 StatisticsData(float min_, float avg_, float max_, float stddev_, boost::uint32_t count_)
45 : min(min_), avg(avg_), max(max_), stddev(stddev_), count(count_) {};
46 StatisticsData(StatisticsData const & other)
47 : min(other.min), avg(other.avg), max(other.max), stddev(other.stddev), count(other.count) {};
49 : min(0.0), avg(0.0), max(0.0), stddev(0.0), count(0) {};
55 boost::uint32_t count;
58 std::ostream & operator<<(std::ostream & os, StatisticsData const & _data);
60 /** \brief Accumulate measurement values
62 The accumulator mainly do the prelimenary work for the senf::Statistic class.
63 It accumulates certain values with in an interval to be used by senf::Statistics
65 \li the senf::Statistics class
66 \li statistics sources
68 This class provides the average, standard deviation, min, max values over one
69 interval, means until clear() is called. It rather directly calculates the results
70 then collection all single values provided by calling accumulate().
71 \see senf::Statistics to process accumulated values
72 \ingroup senf_statistics
75 class StatisticAccumulator
78 StatisticAccumulator();
80 void clear(); ///< Reset accumulated values.
81 /**< This member reset all values. */
82 void accumulate(T value); ///< Gather value to be accumulated.
83 /**< This method accumulates a value.
84 \param[in] value to be accumulated value */
85 void setLastAvg(T value); ///< If no real data was collected, this method specifies the min/avg/max value to be returned.
86 /**< This method specifies the the min/avg/max value to
87 be returned if no real data was collected
88 \param[in] value to be returned */
90 T min() const; ///< Returns current minimal value.
91 /**< This method returns the minimal value of the
92 current accumulation. */
93 T max() const; ///< Returns current maximal value.
94 /**< This method returns the maximal value of the
95 current accumulation.*/
96 float avg() const; ///< Returns average value.
97 /**< This method returns the average value of the
98 current accumulation.*/
99 float last_avg() const; ///< Returns former average value.
100 /**< This method returns the average value of the
101 former accumulation period.*/
102 float stddev() const; ///< Returns standard deviation value.
103 /**< This method returns the standard deviation
104 value of the current accumulation.*/
105 boost::uint32_t count() const; ///< Returns count of accumulated values.
106 /**< This method returns count of accumulated
107 values of the current accumulation.*/
108 void data(StatisticsData & data_) const;
109 ///< Returns the accumulated data as a tuple
110 /**< This method returns the accumulated information
118 boost::uint32_t count_;
122 ///////////////////////////////hh.e////////////////////////////////////////
123 //#include "StatisticAccumulator.cci"
124 #include "StatisticAccumulator.ct"
125 #include "StatisticAccumulator.cti"