Line data Source code
1 : #ifndef ERROR_HANDLER_MA_FREQUENCY_H
2 : #define ERROR_HANDLER_MA_FREQUENCY_H
3 :
4 : #include "ErrorHandler/MessageAnalyzer/ma_utils.h"
5 :
6 : #include <boost/multi_array.hpp>
7 : #include <boost/regex.hpp>
8 :
9 : namespace novadaq {
10 : namespace errorhandler {
11 :
12 : class ma_cell
13 : {
14 : public:
15 : ma_cell();
16 : ~ma_cell();
17 :
18 : // reset to ground state
19 : void
20 : reset();
21 :
22 : // call hit method when a message passes filtering and match tests
23 : // returns true if the status has changed (off->on or on->off), or
24 : // false if not
25 : //
26 : // if persistent (persistent=true), the status never turns off.
27 : // otherwise, the status can change to off when it slides out of
28 : // the time window
29 : bool
30 : hit(qt_mf_msg const& msg, boost::smatch const& w, ma_condition& cond, size_t s_idx, size_t t_idx);
31 :
32 : bool event(time_t t, ma_condition& cond);
33 :
34 : // get status
35 : bool
36 0 : is_on() const { return on; }
37 :
38 : // get number of messages
39 : size_t
40 0 : get_message_count() const { return msgs.size(); }
41 :
42 : // get messages
43 : const msgs_t&
44 : get_messages() const { return msgs; }
45 :
46 : // get latest message
47 : std::string
48 0 : get_latest_message() const
49 : {
50 0 : assert(!msgs.empty());
51 0 : return msgs.back().text(false).toStdString();
52 : }
53 :
54 : // get group
55 : std::string
56 0 : get_message_group(size_t i) const
57 : {
58 0 : if (i > what_.size()) throw std::runtime_error("group does not exist");
59 0 : return std::string(what_[i].first, what_[i].second);
60 : }
61 :
62 : private:
63 : msgs_t msgs;
64 : bool on;
65 :
66 : // groups from last hit
67 : boost::smatch what_;
68 :
69 : // time of next event
70 : time_t t_event;
71 : };
72 :
73 : typedef boost::multi_array<ma_cell, 2> hitmap_t;
74 : typedef hitmap_t::index index_t;
75 :
76 : typedef hitmap_t::const_array_view<2>::type hitmap_view_t;
77 : typedef hitmap_view_t ma_cond_domain_view;
78 : typedef ma_cond_domain_view::const_iterator ma_cond_domain_view_iter;
79 : typedef std::vector<ma_cond_domain_view_iter> ma_cond_domain_view_iters;
80 : typedef std::vector<ma_cond_domain_view> ma_domain_view;
81 : typedef ma_domain_view::const_iterator ma_domain_view_iter;
82 : typedef std::list<ma_domain_view> ma_domain_views;
83 :
84 : typedef boost::multi_array_types::index_range range;
85 :
86 : } // end of namespace errorhandler
87 : } // end of namespace novadaq
88 :
89 : #endif
|