1 #ifndef ERROR_HANDLER_MA_CONDITION_H
2 #define ERROR_HANDLER_MA_CONDITION_H
5 #include "ErrorHandler/MessageAnalyzer/ma_types.h"
6 #include "ErrorHandler/MessageAnalyzer/ma_utils.h"
7 #include "ErrorHandler/MessageAnalyzer/ma_hitmap.h"
8 #include "ErrorHandler/MessageAnalyzer/ma_cond_test_expr.h"
9 #include "ErrorHandler/MessageAnalyzer/ma_timing_event.h"
12 #include <boost/regex.hpp>
13 #include <boost/shared_ptr.hpp>
21 namespace errorhandler {
23 typedef boost::regex regex_t;
24 typedef std::vector<boost::regex> vregex_t;
33 , std::string
const & sev
34 , std::vector<std::string>
const & sources
35 , std::vector<std::string>
const & categories
36 , std::string
const & regex
37 , std::string
const & test
38 ,
bool persistent_cond
61 bool event(
size_t src,
size_t tgt, time_t t, conds_t & status );
64 const std::string & description()
const {
return description_; }
65 const std::string & regex()
const {
return regex_str; }
66 const std::string & sources_str()
const {
return srcs_str; }
72 int get_msg_count ( )
const {
return catched_messages; }
75 sev_code_t get_msg_severity( )
const {
return last_sev_; }
76 const std::string & get_msg_category( )
const {
return last_cat_; }
77 const std::string & get_msg_source ( )
const {
return last_src_; }
78 const std::string & get_qt_mf_msgarget ( )
const {
return last_tgt_; }
79 const std::string & get_msg_body ( )
const {
return last_bdy_; }
80 std::string get_msg_group (
size_t i )
const
81 {
if(i>last_what_.size())
throw std::runtime_error(
"group does not exist");
82 return std::string(last_what_[i].first, last_what_[i].second); }
85 int find_source(std::string
const & src) {
return hitmap.find_source(src); }
86 int find_target(std::string
const & tgt) {
return hitmap.find_target(tgt); }
87 int find_arg(std::string
const & arg, arg_t type)
88 {
return (type==SOURCE) ? hitmap.find_source(arg) : hitmap.find_target(arg); }
91 const idx_t & get_sources()
const {
return hitmap.get_sources(); }
92 const idx_t & get_targets()
const {
return hitmap.get_targets(); }
93 const idx_t & get_args(arg_t type)
const
94 {
if( type==SOURCE )
return hitmap.get_sources();
95 if( type==TARGET )
return hitmap.get_targets();
96 throw std::runtime_error(
"condition::get_args() unsupported arg type"); }
99 const std::string & get_source( ma_cond_domain v )
const
100 {
return hitmap.get_source(v); }
101 const std::string & get_target( ma_cond_domain v )
const
102 {
return hitmap.get_target(v); }
103 std::string get_arg( ma_cond_domain v, arg_t type )
const
104 {
if( type==SOURCE )
return hitmap.get_source(v);
105 if( type==TARGET )
return hitmap.get_target(v);
106 if( type==MESSAGE)
return hitmap.get_message(v);
107 if( type>=GROUP1 )
return hitmap.get_message_group(v, (
size_t)(type-GROUP1+1));
108 throw std::runtime_error(
"condition::get_arg() unknow arg type");
113 get_cond_range( ma_cond_domain d
114 , ma_cond_range & src
115 , ma_cond_range & tgt )
const
116 {
return hitmap.get_cond_range(d, src, tgt); }
120 get_status( ma_cond_domain v )
const
121 {
return hitmap.get_status(v); }
124 get_alarm_count( ma_cond_domain v, arg_t arg )
const
125 {
return hitmap.get_alarm_count(v, arg); }
129 void push_notify_source(
ma_rule * rule ) { push_notify(notify_on_source, rule); }
130 void push_notify_target(
ma_rule * rule ) { push_notify(notify_on_target, rule); }
131 void push_notify_status(
ma_rule * rule ) { push_notify(notify_on_status, rule); }
134 push_notify( notify_list_t & list,
ma_rule * rule )
136 if( std::find(list.begin(), list.end(), rule) == list.end() )
137 list.push_back(rule);
142 { notify_on_source.sort(); notify_on_target.sort(); notify_on_status.sort(); }
144 const notify_list_t &
145 get_notify_list( notify_t type )
147 if( type == STATUS_NOTIFY )
return notify_on_status;
148 if( type == SOURCE_NOTIFY )
return notify_on_source;
149 if( type == TARGET_NOTIFY )
return notify_on_target;
150 throw std::runtime_error(
"get_notify_list: unknow type");
153 int trigger_count()
const {
return tc; }
154 int timespan()
const {
return ts; }
155 bool at_least()
const {
return at_least_; }
156 bool at_most()
const {
return !at_least_; }
157 bool per_source()
const {
return ps; }
158 bool per_target()
const {
return pt; }
159 bool persistent()
const {
return persistent_; }
164 get_domain_view( ma_cond_domain
const & domain )
165 {
return hitmap.get_domain_view(domain); }
171 void extract_fields (
qt_mf_msg const & msg);
181 std::string description_;
184 sev_code_t severity_;
186 std::string srcs_str;
190 std::string cats_str;
195 match_type_t match_type;
196 std::string regex_str;
208 unsigned int t_group;
223 sev_code_t last_sev_;
224 std::string last_src_;
225 std::string last_tgt_;
226 std::string last_cat_;
227 std::string last_bdy_;
228 boost::smatch last_what_;
231 notify_list_t notify_on_source;
232 notify_list_t notify_on_target;
233 notify_list_t notify_on_status;
238 int catched_messages;
247 typedef std::vector<ma_condition *> cond_vec_t;
248 typedef std::map<std::string, ma_condition> cond_map_t;
Qt wrapper around MessageFacility message