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 namespace fty = senf::console::factory;
70 dir.add("list", fty::Command(&OutputEntry::consoleList, this)
71 .doc("List all known connected targets. This list might not be complete.") );
74 prefix_ senf::StatisticsBase::OutputEntry &
75 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
85 prefix_ void senf::StatisticsBase::OutputEntry::consoleList(std::ostream & os)
87 for (boost::ptr_vector<TargetBase>::iterator i (targets_.begin());
88 i != targets_.end(); ++i)
89 if (! i->label.empty())
90 os << i->label << "\n";
93 /////////////////////////////////////////////////////////////////////////
94 // senf::StatisticsBase
96 prefix_ senf::StatisticsBase::StatisticsBase()
97 : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
100 prefix_ senf::StatisticsBase::~StatisticsBase()
103 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
105 return senf::make_transform_range(children_, Transform());
108 prefix_ float senf::StatisticsBase::min()
114 prefix_ float senf::StatisticsBase::avg()
120 prefix_ float senf::StatisticsBase::max()
126 prefix_ float senf::StatisticsBase::dev()
132 prefix_ unsigned senf::StatisticsBase::rank()
138 prefix_ senf::Statistics & senf::StatisticsBase::base()
143 prefix_ std::string senf::StatisticsBase::path()
149 ///////////////////////////////////////////////////////////////////////////
152 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
153 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
157 prefix_ unsigned senf::Collector::rank()
163 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
164 senf::Collector::output(unsigned n)
167 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
170 ///////////////////////////////////////////////////////////////////////////
173 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
175 enter(min, avg, max, dev);
178 prefix_ void senf::Statistics::operator()(float value, float dev)
180 enter(value, value, value, dev);
183 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
184 senf::Statistics::output(unsigned n)
186 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
189 ///////////////////////////////cci.e///////////////////////////////////////
196 // comment-column: 40
197 // c-file-style: "senf"
198 // indent-tabs-mode: nil
199 // ispell-local-dictionary: "american"
200 // compile-command: "scons -u test"