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()
54 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
55 : n(n_), min(), avg(), max()
60 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
61 : n(other.n), min(other.min), avg(other.avg), max(other.max)
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)
82 prefix_ void senf::StatisticsBase::OutputEntry::consoleList(std::ostream & os)
84 for (boost::ptr_vector<TargetBase>::iterator i (targets_.begin());
85 i != targets_.end(); ++i)
86 if (! i->label.empty())
87 os << i->label << "\n";
90 /////////////////////////////////////////////////////////////////////////
91 // senf::StatisticsBase
93 prefix_ senf::StatisticsBase::StatisticsBase()
94 : min_ (0.0f), avg_ (0.0f), max_ (0.0f), maxQueueLen_ (0u)
97 prefix_ senf::StatisticsBase::~StatisticsBase()
100 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
102 return senf::make_transform_range(children_, Transform());
105 prefix_ float senf::StatisticsBase::min()
111 prefix_ float senf::StatisticsBase::avg()
117 prefix_ float senf::StatisticsBase::max()
123 prefix_ unsigned senf::StatisticsBase::rank()
129 prefix_ senf::Statistics & senf::StatisticsBase::base()
134 prefix_ std::string senf::StatisticsBase::path()
140 ///////////////////////////////////////////////////////////////////////////
143 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
144 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accAvg_ (0.0f), accMax_ (-FLT_MAX),
148 prefix_ unsigned senf::Collector::rank()
154 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
155 senf::Collector::output(unsigned n)
158 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
161 ///////////////////////////////////////////////////////////////////////////
164 prefix_ void senf::Statistics::operator()(float min, float avg, float max)
166 enter(min, avg, max);
169 prefix_ void senf::Statistics::operator()(float value)
171 enter(value, value, value);
174 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
175 senf::Statistics::output(unsigned n)
177 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
180 ///////////////////////////////cci.e///////////////////////////////////////
187 // comment-column: 40
188 // c-file-style: "senf"
189 // indent-tabs-mode: nil
190 // ispell-local-dictionary: "american"
191 // compile-command: "scons -u test"