StatisticsTargets.ih
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 StatisticsTargets internal header */
16 
17 #ifndef IH_SENF_Utils_StatisticsTargets_
18 #define IH_SENF_Utils_StatisticsTargets_ 1
19 
20 // Custom includes
21 #include <string>
22 #include <senf/Utils/singleton.hh>
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
28  namespace console { class DirectoryNode; }
29 
30  class StatisticsBase;
31 
32 namespace detail {
33 
34  class StatisticsLoggerRegistry
35  : public senf::singleton<StatisticsLoggerRegistry>
36  {
37  public:
38  typedef void (*AddFn)(senf::StatisticsBase &, unsigned,
39  senf::console::DirectoryNode &);
40 
41  using senf::singleton<StatisticsLoggerRegistry>::instance;
42  using senf::singleton<StatisticsLoggerRegistry>::alive;
43 
44  void add(AddFn fn);
45  void apply(senf::StatisticsBase & stats, unsigned rank,
46  senf::console::DirectoryNode & dir);
47 
48  private:
49  typedef std::vector<AddFn> Adders;
50  Adders adders_;
51  };
52 
53  template <class Stream=void, class Area=void, class Level=void>
54  struct StatisticsLogger
55  : boost::noncopyable
56  {
57  StatisticsLogger(std::string const & label_);
58  void operator()(unsigned cnt, float min, float avg, float max, float dev);
59 
60  std::string label;
61  };
62 
63 }}
64 
65 //-/////////////////////////////////////////////////////////////////////////////////////////////////
66 #endif
67 
68 
69 // Local Variables:
70 // mode: c++
71 // fill-column: 100
72 // comment-column: 40
73 // c-file-style: "senf"
74 // indent-tabs-mode: nil
75 // ispell-local-dictionary: "american"
76 // compile-command: "scons -u test"
77 // End: