2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief Statistics inline template implementation */
17 //#include "Statistics.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::StatisticsBase::OutputProxy
27 template <class Owner>
28 prefix_ senf::StatisticsBase::OutputProxy<Owner>::OutputProxy(Owner * owner, OutputEntry * entry)
29 : owner_ (owner), entry_ (entry)
32 template <class Owner>
33 template <class OtherOwner>
34 prefix_ senf::StatisticsBase::OutputProxy<Owner>::
35 OutputProxy(Owner * owner, OutputProxy<OtherOwner> const & other)
36 : owner_ (owner), entry_ (other.entry_)
39 template <class Owner>
40 template <class Target>
41 prefix_ Owner & senf::StatisticsBase::OutputProxy<Owner>::connect(Target & target, std::string label)
45 label = prettyName(typeid(Target));
46 entry_->signal.connect(boost::ref(target));
47 entry_->targets_.push_back(new OutputEntry::Target<Target>(label));
51 template <class Owner>
52 template <class PTarget>
54 senf::StatisticsBase::OutputProxy<Owner>::connect(std::unique_ptr<PTarget> target, std::string label)
58 label = prettyName(typeid(PTarget));
59 PTarget * targetp (target.get());
60 entry_->targets_.push_back(new OutputEntry::Target<PTarget>(std::move(target),label));
61 entry_->signal.connect(boost::ref(*targetp));
65 template <class Owner>
66 prefix_ Owner & senf::StatisticsBase::OutputProxy<Owner>::noconnect()
72 template <class Owner>
73 prefix_ senf::console::ScopedDirectory<> & senf::StatisticsBase::OutputProxy<Owner>::dir()
79 ///////////////////////////////////////////////////////////////////////////
82 template <class Value>
83 prefix_ void senf::Statistics::operator()(unsigned n, StatisticAccumulator<Value> & sa)
85 enter(n, sa.count(), float(sa.min()), sa.avg(), float(sa.max()), sa.stddev());
90 //-/////////////////////////////////////////////////////////////////////////////////////////////////
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"