-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathVariantVisitorAdd.h
More file actions
39 lines (34 loc) · 1.18 KB
/
VariantVisitorAdd.h
File metadata and controls
39 lines (34 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace o2
{
// ALICE O2 Monitoring system
namespace monitoring
{
/// \brief Adds boost variants
class VariantVisitorAdd : public boost::static_visitor<boost::variant<int, std::string, double, uint64_t>>
{
public:
/// Overloads operator() to avoid operating on strings
/// \throws MonitoringInternalException
double operator()(const std::string&, const std::string&) const {
throw MonitoringInternalException("DerivedMetrics/VariantRateVisitor", "Cannot operate on string values");
}
/// Calculates rate only when two arguments of the same type are passed
/// \return calculated rate in Hz
int operator()(const int& a, const int& b) const {
return a + b;
}
double operator()(const double& a, const double& b) const {
return a + b;
}
uint64_t operator()(const uint64_t& a, const uint64_t& b) const {
return a + b;
}
/// If arguments have different type an exception is raised
/// \throws MonitoringInternalException
template<typename T, typename U>
double operator()(const T&, const U&) const {
throw MonitoringInternalException("DerivedMetrics/VariantRateVisitor", "Cannot operate on different types");
}
};
} // namespace monitoring
} // namespace o2