Statistics.cti
Go to the documentation of this file.
1 //
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
6 //
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
11 //
12 
13 
14 /** \file
15  \brief Statistics inline template implementation */
16 
17 //#include "Statistics.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::StatisticsBase::OutputProxy
26 
27 template <class Owner>
28 prefix_ senf::StatisticsBase::OutputProxy<Owner>::OutputProxy(Owner * owner, OutputEntry * entry)
29  : owner_ (owner), entry_ (entry)
30 {}
31 
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_)
37 {}
38 
39 template <class Owner>
40 template <class Target>
41 prefix_ Owner & senf::StatisticsBase::OutputProxy<Owner>::connect(Target & target, std::string label)
42  const
43 {
44  if (label.empty())
45  label = prettyName(typeid(Target));
46  entry_->signal.connect(boost::ref(target));
47  entry_->targets_.push_back(new OutputEntry::Target<Target>(label));
48  return * owner_;
49 }
50 
51 template <class Owner>
52 template <class PTarget>
53 prefix_ Owner &
54 senf::StatisticsBase::OutputProxy<Owner>::connect(std::unique_ptr<PTarget> target, std::string label)
55  const
56 {
57  if (label.empty())
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));
62  return * owner_;
63 }
64 
65 template <class Owner>
66 prefix_ Owner & senf::StatisticsBase::OutputProxy<Owner>::noconnect()
67  const
68 {
69  return * owner_;
70 }
71 
72 template <class Owner>
73 prefix_ senf::console::ScopedDirectory<> & senf::StatisticsBase::OutputProxy<Owner>::dir()
74  const
75 {
76  return entry_->dir;
77 }
78 
79 ///////////////////////////////////////////////////////////////////////////
80 // senf::Statistics
81 
82 template <class Value>
83 prefix_ void senf::Statistics::operator()(unsigned n, StatisticAccumulator<Value> & sa)
84 {
85  enter(n, sa.count(), float(sa.min()), sa.avg(), float(sa.max()), sa.stddev());
86  sa.clear();
87 }
88 
89 
90 //-/////////////////////////////////////////////////////////////////////////////////////////////////
91 #undef prefix_
92 
93 
94 // Local Variables:
95 // mode: c++
96 // fill-column: 100
97 // comment-column: 40
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"
102 // End: