ewmscp  ..
Public Member Functions | Public Attributes | Private Member Functions | List of all members
statCollector::typed< T > Class Template Reference

#include <statCollector.h>

Inheritance diagram for statCollector::typed< T >:
[legend]
Collaboration diagram for statCollector::typed< T >:
[legend]

Public Member Functions

void addValue (T value)
 
template<typename TT = T, typename std::enable_if< std::is_arithmetic< TT >::value >::type... , class ... Types>
 typed (Types ... args)
 
template<typename TT = T, typename std::enable_if< !std::is_arithmetic< TT >::value >::type... , class ... Types>
 typed (Types ... args)
 
void print (std::ostream &stream) const override
 
void reset () override
 
- Public Member Functions inherited from statCollector::base
 base (const std::string &aName, const std::string &aUnit="s")
 
const std::string & getName () const
 
const std::string & getUnit () const
 
decltype(ngetN () const
 

Public Attributes

sum
 
min
 
max
 

Private Member Functions

template<typename TT = T>
std::enable_if< !std::is_arithmetic< TT >::value >::type _print (std::ostream &stream) const
 
template<typename TT = T>
std::enable_if< std::is_arithmetic< TT >::value >::type _print (std::ostream &stream) const
 
template<typename TT = T>
std::enable_if< !std::is_arithmetic< TT >::value >::type _reset ()
 
template<typename TT = T>
std::enable_if< std::is_arithmetic< TT >::value >::type _reset ()
 

Additional Inherited Members

- Protected Attributes inherited from statCollector::base
unsigned long long n
 

Detailed Description

template<typename T>
class statCollector::typed< T >

Definition at line 32 of file statCollector.h.

Constructor & Destructor Documentation

◆ typed() [1/2]

template<typename T >
template<typename TT = T, typename std::enable_if< std::is_arithmetic< TT >::value >::type... , class ... Types>
statCollector::typed< T >::typed ( Types ...  args)
inline

Definition at line 48 of file statCollector.h.

48  :
49  base(args...),
50  sum(0),
51  min(std::numeric_limits<T>::max()),
52  max(std::numeric_limits<T>::lowest()) {
53  };

◆ typed() [2/2]

template<typename T >
template<typename TT = T, typename std::enable_if< !std::is_arithmetic< TT >::value >::type... , class ... Types>
statCollector::typed< T >::typed ( Types ...  args)
inline

Definition at line 55 of file statCollector.h.

55  :
56  base(args...),
57  sum(T::zero()),
58  min(T::max()),
59  max(T::min()) {
60  };

Member Function Documentation

◆ _print() [1/2]

template<typename T >
template<typename TT = T>
std::enable_if< !std::is_arithmetic<TT>::value >::type statCollector::typed< T >::_print ( std::ostream &  stream) const
inlineprivate

Definition at line 65 of file statCollector.h.

65  {
66  stream << this->getName() << " avg: " << std::scientific
67  << std::chrono::duration_cast<std::chrono::duration<double>>(sum / this->n).count()
68  << this->getUnit() << ", min: "
69  << std::chrono::duration_cast<std::chrono::duration<double>>(min).count()
70  << this->getUnit() << ", max: "
71  << std::chrono::duration_cast<std::chrono::duration<double>>(max).count()
72  << this->getUnit();
73  }

Referenced by statCollector::typed< decltype(tWorkDone - tWorkStart) >::print().

Here is the caller graph for this function:

◆ _print() [2/2]

template<typename T >
template<typename TT = T>
std::enable_if<std::is_arithmetic<TT>::value>::type statCollector::typed< T >::_print ( std::ostream &  stream) const
inlineprivate

Definition at line 76 of file statCollector.h.

76  {
77  stream << this->getName() << " avg: "
78  << sum / this->n
79  << this->getUnit() << ", min: "
80  << min
81  << this->getUnit() << ", max: "
82  << max
83  << this->getUnit();
84  }

◆ _reset() [1/2]

template<typename T >
template<typename TT = T>
std::enable_if< !std::is_arithmetic<TT>::value >::type statCollector::typed< T >::_reset ( )
inlineprivate

Definition at line 96 of file statCollector.h.

96  {
97  sum = T::zero();
98  min =T::max();
99  max = T::min();
100  }

Referenced by statCollector::typed< decltype(tWorkDone - tWorkStart) >::reset().

Here is the caller graph for this function:

◆ _reset() [2/2]

template<typename T >
template<typename TT = T>
std::enable_if<std::is_arithmetic<TT>::value>::type statCollector::typed< T >::_reset ( )
inlineprivate

Definition at line 103 of file statCollector.h.

103  {
104  sum=0;
105  min=std::numeric_limits<T>::max();
106  max=std::numeric_limits<T>::lowest();
107  }

◆ addValue()

template<typename T >
void statCollector::typed< T >::addValue ( value)
inline

Definition at line 37 of file statCollector.h.

37  {
38  sum += value;
39  if (value < min) {
40  min = value;
41  }
42  if (value > max) {
43  max = value;
44  }
45  this->n++;
46  };

Referenced by followInotifyWatchRequestProvider::followStream().

Here is the caller graph for this function:

◆ print()

template<typename T >
void statCollector::typed< T >::print ( std::ostream &  stream) const
inlineoverridevirtual

Implements statCollector::base.

Definition at line 86 of file statCollector.h.

86  {
87  if (n) {
88  _print(stream);
89  } else {
90  stream << this->getName() << " no values yet ";
91  }
92  }

◆ reset()

template<typename T >
void statCollector::typed< T >::reset ( )
inlineoverridevirtual

Implements statCollector::base.

Definition at line 109 of file statCollector.h.

109  {
110  n=0;
111  _reset();
112  }

Member Data Documentation

◆ max

template<typename T >
T statCollector::typed< T >::max

◆ min

template<typename T >
T statCollector::typed< T >::min

◆ sum

template<typename T >
T statCollector::typed< T >::sum

The documentation for this class was generated from the following file:
statCollector::typed::max
T max
Definition: statCollector.h:36
statCollector::base::n
unsigned long long n
Definition: statCollector.h:10
statCollector::typed::min
T min
Definition: statCollector.h:35
statCollector::base::base
base(const std::string &aName, const std::string &aUnit="s")
Definition: statCollector.h:12
statCollector::typed::_reset
std::enable_if< !std::is_arithmetic< TT >::value >::type _reset()
Definition: statCollector.h:96
statCollector::typed::_print
std::enable_if< !std::is_arithmetic< TT >::value >::type _print(std::ostream &stream) const
Definition: statCollector.h:65
statCollector::typed::sum
T sum
Definition: statCollector.h:34
statCollector::base::getUnit
const std::string & getUnit() const
Definition: statCollector.h:23
statCollector::base::getName
const std::string & getName() const
Definition: statCollector.h:20