4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.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 Statistics inline non-template implementation */
26 //#include "Statistics.ih"
32 #define prefix_ inline
33 ///////////////////////////////cci.p///////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////////
36 // senf::StatisticsBase::Transform
38 prefix_ senf::StatisticsBase::Transform::result_type
39 senf::StatisticsBase::Transform::operator()(first_argument_type i)
45 ///////////////////////////////////////////////////////////////////////////
46 // senf::StatisticsBase::OutputEntry
48 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
49 : n(), min(), avg(), max(), dev()
54 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
55 : n(n_), min(), avg(), max(), dev()
60 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
61 : n(other.n), min(other.min), avg(other.avg), max(other.max), dev(other.dev)
66 prefix_ void senf::StatisticsBase::OutputEntry::initDir()
68 dir.add("list", senf::membind(&OutputEntry::consoleList, this))
69 .doc("List all known connected targets. This list might not be complete.");
72 prefix_ senf::StatisticsBase::OutputEntry &
73 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
83 prefix_ void senf::StatisticsBase::OutputEntry::consoleList(std::ostream & os)
85 for (boost::ptr_vector<TargetBase>::iterator i (targets_.begin());
86 i != targets_.end(); ++i)
87 if (! i->label.empty())
88 os << i->label << "\n";
91 /////////////////////////////////////////////////////////////////////////
92 // senf::StatisticsBase
94 prefix_ senf::StatisticsBase::StatisticsBase()
95 : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
98 prefix_ senf::StatisticsBase::~StatisticsBase()
101 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
103 return senf::make_transform_range(children_, Transform());
106 prefix_ float senf::StatisticsBase::min()
112 prefix_ float senf::StatisticsBase::avg()
118 prefix_ float senf::StatisticsBase::max()
124 prefix_ float senf::StatisticsBase::dev()
130 prefix_ unsigned senf::StatisticsBase::rank()
136 prefix_ senf::Statistics & senf::StatisticsBase::base()
141 prefix_ std::string senf::StatisticsBase::path()
147 ///////////////////////////////////////////////////////////////////////////
150 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
151 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
155 prefix_ unsigned senf::Collector::rank()
161 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
162 senf::Collector::output(unsigned n)
165 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
168 ///////////////////////////////////////////////////////////////////////////
171 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
173 enter(min, avg, max, dev);
176 prefix_ void senf::Statistics::operator()(float value, float dev)
178 enter(value, value, value, dev);
181 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
182 senf::Statistics::output(unsigned n)
184 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
187 ///////////////////////////////cci.e///////////////////////////////////////
194 // comment-column: 40
195 // c-file-style: "senf"
196 // indent-tabs-mode: nil
197 // ispell-local-dictionary: "american"
198 // compile-command: "scons -u test"