X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FStatisticAccumulator.hh;fp=senf%2FUtils%2FStatisticAccumulator.hh;h=6c08c41097deae6bf0986ba495274bd8084cca7d;hb=2ed56fbec2aa25bf4a8b13e6a06ec90e9dcc1fec;hp=0000000000000000000000000000000000000000;hpb=4101c2b818ec67e7469ebb44f030eed2185c4ab0;p=senf.git diff --git a/senf/Utils/StatisticAccumulator.hh b/senf/Utils/StatisticAccumulator.hh new file mode 100644 index 0000000..6c08c41 --- /dev/null +++ b/senf/Utils/StatisticAccumulator.hh @@ -0,0 +1,108 @@ +// $Id$ +// +// Copyright (C) 2010 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief StatisticAccumulator public header */ + +#ifndef HH_SENF_Utils_StatisticAccumulator_ +#define HH_SENF_Utils_StatisticAccumulator_ 1 + +// Custom includes +#include +#include +///////////////////////////////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 + */ + + template + class StatisticAccumulator + { + public: + StatisticAccumulator( T defaultvalue = 0); +// 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. */ + void accumulate(T value); + ///< Gather value to be accumulated. + /**< This method accumulate a value. + \param[in] value to be accumulated value*/ + + public: + T min() const; + ///< Returns current minimal value. + /**< This method returns the minimal value of the current accumulation.*/ + T max() const; + ///< Returns current maximal value. + /**< This method returns the maximal value of the current accumulation.*/ + float avg() const; + ///< Returns average value. + /**< This method returns the average value of the current accumulation.*/ + float last_avg() const; + ///< Returns former average value. + /**< This method returns the average value of the former accumulation period.*/ + float stddev() const; + ///< Returns standard deviation value. + /**< This method returns the standard deviation value of the current accumulation.*/ + boost::uint32_t count() const; + ///< Returns count of accumulated values. + /**< This method returns count of accumulated values of the current accumulation.*/ + + private: + T defaultvalue_; + T sum_squared_; + T sum_; + T min_; + T max_; + float last_avg_; + boost::uint32_t count_; + + + }; + + + typedef StatisticAccumulator StatisticAccumulatorInt; + typedef StatisticAccumulator StatisticAccumulatorFloat; + + +} +///////////////////////////////hh.e//////////////////////////////////////// +//#include "StatisticAccumulator.cci" +#include "StatisticAccumulator.ct" +#include "StatisticAccumulator.cti" +#endif +