Monitoring  3.3.4
O2 Monitoring library
VariantVisitorRate.h
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
11 namespace o2
12 {
13 // ALICE O2 Monitoring system
14 namespace monitoring
15 {
18 {
19  private:
21  int timestampCount;
22 
23  public:
26  VariantVisitorRate(int count) : timestampCount(count)
27  {
28  }
29 
32  template <
33  typename T,
34  typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
35  double operator()(const T& a, const T& b) const
36  {
37  return (1000 * (static_cast<double>(a) - b)) / timestampCount;
38  }
39 
42  template <typename T, typename U>
43  double operator()(const T&, const U&) const
44  {
45  throw MonitoringException("DerivedMetrics/Visitor", "Cannot operate on different or non-numeric types");
46  }
47 };
48 
49 } // namespace monitoring
50 } // namespace o2
Definition: Backend.h:23
Subtracts boost variants in order to calculate rate.
Definition: VariantVisitorRate.h:17
double operator()(const T &a, const T &b) const
Definition: VariantVisitorRate.h:35
VariantVisitorRate(int count)
Definition: VariantVisitorRate.h:26
Internal monitoring exception.
Definition: MonitoringException.h:29
double operator()(const T &, const U &) const
Definition: VariantVisitorRate.h:43