artdaq_mfextensions  v1_06_02
ma_domain_cond.h
1 #ifndef ERROR_HANDLER_MA_DOMAIN_COND_H
2 #define ERROR_HANDLER_MA_DOMAIN_COND_H
3 
4 // from novadaq
5 #include "ErrorHandler/MessageAnalyzer/ma_condition.h"
6 #include "ErrorHandler/MessageAnalyzer/ma_types.h"
7 
8 // from ups
9 #include <boost/shared_ptr.hpp>
10 
11 // from system
12 #include <list>
13 
14 namespace novadaq {
15 namespace errorhandler {
16 
17 // An elemental domain condition could be one of the followings:
18 // 1. rule_cond_1.$[s|t] = rule_cond_2.$[s|t] ( = "string literal" )
19 // 2. '(' >> domain_expr >> ')'
20 
21 class ma_rule;
22 class ma_domain_expr;
23 
25 {
26 public:
28 
29  // evaluate domains of this ma_domain_cond, then merge the
30  // result with passed in domains
31  void evaluate(ma_domains& domains) const;
32 
33  // insert condition idx and $s/$t
34  void insert_cond_arg(cond_idx_t ci, arg_t arg, size_t size)
35  {
36  conds.push_back(std::make_pair(ci, arg));
37  cond_size = size;
38  }
39 
40  // insert string condition ( cond.$s = 'str_cond' )
41  void insert_str_cond(std::string const& str)
42  {
43  str_cond = str;
44  }
45 
46  // insert domain_expr ( cond_type = EXPR )
47  void insert_expr(ma_domain_expr const& expr);
48 
49  // and-merge domains from worksheet into domains
50  ma_domains&
51  and_merge(ma_domains& domains, ma_domains& worksheet) const;
52 
53 private:
54  // type of this elemental condition
55  cond_type_t cond_type;
56 
57  // case CONDS: rule_cond_args connected with '='
58  cond_arg_list_t conds;
59  std::string str_cond;
60  size_t cond_size; // # of conds in the parent rule
61 
62  // case EXPR: an expression
63  // it has to be a ptr to domain_expression to avoid circulic inclusion
64  boost::shared_ptr<ma_domain_expr> expr;
65 };
66 
67 typedef std::list<ma_domain_cond> domain_conds_t;
68 
69 } // end of namespace errorhandler
70 } // end of namespace novadaq
71 
72 #endif