artdaq_mfextensions  v1_03_01
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 "messagefacility/Utilities/ELseverityLevel.h"
16 #include <sys/time.h>
17 
18 namespace mf
19 {
20  class ErrorObj;
21 }
22 
26 enum sev_code_t
27 {
28  SDEBUG,
29  SINFO,
30  SWARNING,
31  SERROR
32 };
33 
37 class qt_mf_msg
38 {
39 public:
43  qt_mf_msg(std::string hostname, std::string category, std::string application, pid_t pid, timeval time);
44 
45  qt_mf_msg() {}
46  qt_mf_msg(const qt_mf_msg&) = default;
47 
48  // get method
54  QString const& text(bool mode) const { return mode ? shortText_ : text_; }
59  QColor const& color() const { return color_; }
64  sev_code_t sev() const { return sev_; }
69  QString const& host() const { return host_; }
74  QString const& cat() const { return cat_; }
79  QString const& app() const { return app_; }
84  timeval time() const { return time_; }
89  size_t seq() const { return seq_; }
90 
91  void setSeverity(mf::ELseverityLevel sev);
92  void setSeverityLevel(sev_code_t sev) { sev_ = sev; }
93  void setMessage(std::string prefix, int iteration, std::string msg);
94  void setHostAddr(std::string hostaddr) { hostaddr_ = QString(hostaddr.c_str()).toHtmlEscaped(); }
95  void setFileName(std::string file) { file_ = QString(file.c_str()).toHtmlEscaped(); }
96  void setLineNumber(std::string line) { line_ = QString(line.c_str()).toHtmlEscaped(); }
97  void setModule(std::string module) { module_ = QString(module.c_str()).toHtmlEscaped(); }
98  void setEventID(std::string eventID) { eventID_ = QString(eventID.c_str()).toHtmlEscaped(); }
99 
100  void updateText();
101 private:
102 
103  QString text_;
104  QString shortText_;
105  QColor color_;
106  sev_code_t sev_;
107  QString host_;
108  QString cat_;
109  QString app_;
110  timeval time_;
111  size_t seq_;
112  static size_t sequence;
113 
114  QString msg_;
115  QString application_;
116  QString pid_;
117  QString hostaddr_;
118  QString file_;
119  QString line_;
120  QString module_;
121  QString eventID_;
122  QString sourceType_;
123  int sourceSequence_;
124 };
125 
129 typedef std::list<qt_mf_msg> msgs_t;
130 
135 {
136 public:
137 
142  msg_iter_t(msgs_t::iterator it)
143  {
144  iter_ = it;
145  seq_ = it->seq();
146  }
147 
153  bool operator==(msg_iter_t const& other) const
154  {
155  return seq_ == other.seq_;
156  }
157 
163  bool operator<(msg_iter_t const& other) const
164  {
165  return seq_ < other.seq_;
166  }
167 
172  msgs_t::iterator get() const { return iter_; };
173 
174 
175 private:
176 
177  msgs_t::iterator iter_;
178  size_t seq_;
179 };
180 
184 typedef std::list<msg_iter_t> msg_iters_t;
188 typedef std::map<QString, msg_iters_t> msg_iters_map_t;
189 
190 #endif
QString const & app() const
Get the application of the message
Definition: qt_mf_msg.hh:79
timeval time() const
Get the message timestamp
Definition: qt_mf_msg.hh:84
size_t seq() const
Get the sequence number of the message
Definition: qt_mf_msg.hh:89
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37
sev_code_t sev() const
Get the severity of the message
Definition: qt_mf_msg.hh:64
msg_iter_t(msgs_t::iterator it)
Construct a msg_iter_t
Definition: qt_mf_msg.hh:142
QString const & host() const
Get the host from which the message came
Definition: qt_mf_msg.hh:69
bool operator<(msg_iter_t const &other) const
Comparison operator, based on message sequence number
Definition: qt_mf_msg.hh:163
Iterator for the msgs_t type
Definition: qt_mf_msg.hh:134
QString const & text(bool mode) const
Get the text of the message
Definition: qt_mf_msg.hh:54
QString const & cat() const
Get the category of the message
Definition: qt_mf_msg.hh:74
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:153
QColor const & color() const
Get the severity-based color of the message
Definition: qt_mf_msg.hh:59