artdaq_mfextensions  v1_05_00
ma_types.h
1 #ifndef ERROR_HANDLER_MA_TYPES_H
2 #define ERROR_HANDLER_MA_TYPES_H
3 
4 /*
5  *
6  * ma_types.h has all typedefs and enums needed in the
7  * message analyzer package
8  *
9  */
10 
11 // includes from ups
12 #include <messagefacility/MessageLogger/MessageLogger.h>
13 #include "mfextensions/Receivers/qt_mf_msg.hh" // sev_code_t
14 
15 #include <boost/multi_array.hpp>
16 
17 // system includes
18 #include <list>
19 #include <memory>
20 #include <functional>
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 #include <TRACE/trace.h>
26 
27 namespace novadaq {
28 namespace errorhandler {
29 
30 // forward declaration
31 class ma_condition;
32 class ma_rule;
33 
34 // typdefs used in errorhandler
35 typedef std::list<qt_mf_msg> msgs_t;
36 typedef std::shared_ptr<msgs_t> msgs_sp_t;
37 
38 typedef boost::multi_array_types::index_range range;
39 typedef std::map<std::string, size_t> idx_t;
40 
41 // domain of a condition
42 // <source, target>, -1 means all, -2 means null
43 
44 const int D_ANY = -1;
45 const int D_NIL = -2;
46 
47 typedef std::pair<int, int> ma_cond_range;
48 typedef std::pair<int, int> ma_cond_domain;
49 typedef std::list<ma_cond_domain> ma_cond_domains;
50 
51 // one set of domain for all conditions
52 typedef std::vector<ma_cond_domain> ma_domain;
53 
54 // alternative domain sets
55 typedef std::list<ma_domain> ma_domains;
56 typedef std::vector<ma_domain> ma_domain_vec;
57 
58 // enums
59 enum rule_type_t
60 {
61  RULE_SIMPLE,
62  RULE_COMPLEX
63 };
64 enum match_type_t
65 {
66  MATCH_ANY,
67  MATCH_REGEX,
68  MATCH_CONTAINS
69 };
70 enum action_type_t
71 {
72  ACTION_ALERT,
73  ACTION_POP
74 };
75 enum node_type_t
76 {
77  Framework,
78  UserCode,
79  External
80 };
81 
82 // type for elemental domain/boolean cond
83 enum cond_type_t
84 {
85  COND,
86  EXPR,
87  FUNCTION,
88  FUNCTION_BOOL,
89  FUNCTION_INT,
90  FUNCTION_DOUBLE,
91  FUNCTION_STRING
92 };
93 
94 // first element is the pointer to the condition stored in the
95 // ma_rule class. Second element indicating it looks for a source
96 // string or a target string
97 enum arg_t
98 {
99  NONE,
100  SOURCE,
101  TARGET,
102  MESSAGE,
103  GROUP1,
104  GROUP2,
105  GROUP3,
106  GROUP4,
107  GROUP5,
108  GROUP6,
109  GROUP7,
110  GROUP8,
111  GROUP9
112 };
113 
114 typedef std::pair<ma_condition *, size_t> cond_idx_t;
115 typedef std::pair<cond_idx_t, arg_t> cond_arg_t;
116 typedef std::list<cond_arg_t> cond_arg_list_t;
117 
118 // compare operators, <, <=, =, >=, >
119 enum compare_op_t
120 {
121  CO_L,
122  CO_LE,
123  CO_E,
124  CO_NE,
125  CO_GE,
126  CO_G
127 };
128 
129 // notification list
130 enum notify_t
131 {
132  STATUS_NOTIFY,
133  SOURCE_NOTIFY,
134  TARGET_NOTIFY
135 };
136 typedef std::list<ma_rule *> notify_list_t;
137 typedef std::list<ma_condition *> conds_t;
138 
139 // reaction starter: conditions stored in the list will need to notify
140 // rules for changes in status, domain source, or domain target
141 typedef std::list<ma_condition *> reaction_starters_t;
142 
143 // bit pattern indicating if theres
144 // 1. status change
145 // 2. source list change
146 // 3. target list change
147 const unsigned int STATUS_CHANGE = 0x01;
148 const unsigned int SOURCE_CHANGE = 0x02;
149 const unsigned int TARGET_CHANGE = 0x04;
150 
151 // alarm callback funtion type
152 typedef std::function<void(std::string const &, std::string const &)> alarm_fn_t;
153 
154 // condition match callback function type
155 typedef std::function<void(std::string const &)> cond_match_fn_t;
156 
157 // alert message type
158 enum message_type_t
159 {
160  MSG_SYSTEM,
161  MSG_ERROR,
162  MSG_WARNING,
163  MSG_INFO,
164  MSG_DEBUG
165 };
166 
167 } // end of namespace errorhandler
168 } // end of namespace novadaq
169 
170 #endif