artdaq_mfextensions  v1_06_02
ma_tf_grp_to_number.cpp
1 
2 #include "ErrorHandler/MessageAnalyzer/ma_tf_grp_to_number.h"
3 #include "ErrorHandler/MessageAnalyzer/ma_condition.h"
4 
5 #include <boost/lexical_cast.hpp>
6 
7 #include <cstdlib>
8 #include <iostream>
9 using namespace novadaq::errorhandler;
10 
11 REG_MA_TEST_FUNCTION(grp_to_number, ma_tf_grp_to_number)
12 
13 boost::any ma_tf_grp_to_number::evaluate(ma_condition const& cond)
14 {
15  std::string s = cond.get_msg_group(group);
16  std::string lead = s.substr(0, 2);
17 
18  if (lead == "0x" || lead == "0X")
19  {
20  long int v = strtol(s.c_str(), NULL, 0);
21  return boost::any((double)v);
22  }
23  else
24  {
25  double v = boost::lexical_cast<double>(s);
26  return boost::any(v);
27  }
28 }
29 
30 bool ma_tf_grp_to_number::parse_arguments(anys_t const& args)
31 {
32  if (args.size() < 1) return false;
33 
34  group = boost::any_cast<int>(args[0]);
35  return true;
36 }