artdaq_mfextensions  v1_02_02
qt_mf_msg.hh
1 #ifndef MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
2 #define MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
3 
4 // Wrapped mf message type to be used by msgviewer for
5 // the purpose of fast processing
6 
7 #include <QtCore/QString>
8 #include <QtGui/QColor>
9 
10 #include <string>
11 #include <vector>
12 #include <list>
13 #include <map>
14 
15 #include <sys/time.h>
16 
17 namespace mf
18 {
19  class MessageFacilityMsg;
20 }
21 
25 enum sev_code_t
26 {
27  SDEBUG,
28  SINFO,
29  SWARNING,
30  SERROR
31 };
32 
36 class qt_mf_msg
37 {
38 public:
43  explicit qt_mf_msg(mf::MessageFacilityMsg const& msg);
44 
45  // get method
51  QString const& text(bool mode) const { return mode ? shortText_ : text_; }
56  QColor const& color() const { return color_; }
61  sev_code_t sev() const { return sev_; }
66  QString const& host() const { return host_; }
71  QString const& cat() const { return cat_; }
76  QString const& app() const { return app_; }
81  timeval time() const { return time_; }
86  size_t seq() const { return seq_; }
87 
88 private:
89 
90  QString text_;
91  QString shortText_;
92  QColor color_;
93  sev_code_t sev_;
94  QString host_;
95  QString cat_;
96  QString app_;
97  timeval time_;
98  size_t seq_;
99  static size_t sequence;
100 };
101 
105 typedef std::list<qt_mf_msg> msgs_t;
106 
111 {
112 public:
113 
118  msg_iter_t(msgs_t::iterator it)
119  {
120  iter_ = it;
121  seq_ = it->seq();
122  }
123 
129  bool operator==(msg_iter_t const& other) const
130  {
131  return seq_ == other.seq_;
132  }
133 
139  bool operator<(msg_iter_t const& other) const
140  {
141  return seq_ < other.seq_;
142  }
143 
148  msgs_t::iterator get() const { return iter_; };
149 
150 
151 private:
152 
153  msgs_t::iterator iter_;
154  size_t seq_;
155 };
156 
160 typedef std::list<msg_iter_t> msg_iters_t;
164 typedef std::map<QString, msg_iters_t> msg_iters_map_t;
165 
166 #endif
QString const & app() const
Get the application of the message
Definition: qt_mf_msg.hh:76
timeval time() const
Get the message timestamp
Definition: qt_mf_msg.hh:81
size_t seq() const
Get the sequence number of the message
Definition: qt_mf_msg.hh:86
qt_mf_msg(mf::MessageFacilityMsg const &msg)
Construct a qt_mf_msg using the given MessageFacilityMsg
Definition: qt_mf_msg.cc:10
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:36
sev_code_t sev() const
Get the severity of the message
Definition: qt_mf_msg.hh:61
msg_iter_t(msgs_t::iterator it)
Construct a msg_iter_t
Definition: qt_mf_msg.hh:118
QString const & host() const
Get the host from which the message came
Definition: qt_mf_msg.hh:66
bool operator<(msg_iter_t const &other) const
Comparison operator, based on message sequence number
Definition: qt_mf_msg.hh:139
Iterator for the msgs_t type
Definition: qt_mf_msg.hh:110
QString const & text(bool mode) const
Get the text of the message
Definition: qt_mf_msg.hh:51
QString const & cat() const
Get the category of the message
Definition: qt_mf_msg.hh:71
bool operator==(msg_iter_t const &other) const
Equality operator. Equality is based on the message&#39;s sequence number
Definition: qt_mf_msg.hh:129
QColor const & color() const
Get the severity-based color of the message
Definition: qt_mf_msg.hh:56