@@ -4,29 +4,38 @@ namespace AliceO2
44namespace Monitoring
55{
66
7- class VariantVisitor : public boost ::static_visitor<boost::variant<int , std::string, double , int64_t >>
7+ class VariantVisitorRate : public boost ::static_visitor<boost::variant<int , std::string, double , int64_t >>
88{
99private:
10+ // / Timestamp difference in milliseconds
1011 int timestampCount;
12+
1113public:
12- VariantVisitor (int count) {
13- timestampCount = count;
14+ // / Creates variant visitor functor
15+ // / \param count timestamp difference in milliseconds
16+ VariantVisitorRate (int count) : timestampCount(count) {
1417 }
1518
19+ // / Overloads operator() to avoid operating on strings
20+ // / \throws MonitoringInternalException
1621 boost::variant<int , std::string, double , int64_t > operator ()(const std::string& a, const std::string& b) const {
17- std::cout << " skipping string " << std::endl ;
22+ throw MonitoringInternalException ( " DerivedMetrics/VariantRateVisitor " , " Cannot operate on string values " ) ;
1823 }
1924
25+ // / Calculates rate only when two arguments of the same type are passed
26+ // / \return calculated rate in Hz
2027 template <typename T>
2128 boost::variant<int , std::string, double , int64_t > operator ()(const T& a, const T& b) const {
2229 return (1000 *(a - b)) / timestampCount;
2330 }
2431
32+ // / If arguments have different type an exception is raised
33+ // / \throws MonitoringInternalException
2534 template <typename T, typename U>
2635 boost::variant<int , std::string, double , int64_t > operator ()(const T& a, const U& b) const {
27- throw std::invalid_argument ( " can't operate on different types" );
36+ throw MonitoringInternalException ( " DerivedMetrics/VariantRateVisitor " , " Cannot operate on different types" );
2837 }
2938};
3039
31- }
32- }
40+ } // namespace Monitoring
41+ } // namespace AliceO2
0 commit comments