artdaq_mfextensions  v1_03_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 "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:
48  qt_mf_msg(std::string hostname, std::string category, std::string application, pid_t pid, timeval time);
49 
51  qt_mf_msg() {}
53  qt_mf_msg(const qt_mf_msg&) = default;
54 
55  // get method
61  QString const& text(bool mode) const { return mode ? shortText_ : text_; }
66  QColor const& color() const { return color_; }
71  sev_code_t sev() const { return sev_; }
76  QString const& host() const { return host_; }
81  QString const& cat() const { return cat_; }
86  QString const& app() const { return app_; }
91  timeval time() const { return time_; }
96  size_t seq() const { return seq_; }
97 
102  void setSeverity(mf::ELseverityLevel sev);
107  void setSeverityLevel(sev_code_t sev) { sev_ = sev; }
114  void setMessage(std::string prefix, int iteration, std::string msg);
119  void setHostAddr(std::string hostaddr) { hostaddr_ = QString(hostaddr.c_str()).toHtmlEscaped(); }
124  void setFileName(std::string file) { file_ = QString(file.c_str()).toHtmlEscaped(); }
129  void setLineNumber(std::string line) { line_ = QString(line.c_str()).toHtmlEscaped(); }
134  void setModule(std::string module) { module_ = QString(module.c_str()).toHtmlEscaped(); }
139  void setEventID(std::string eventID) { eventID_ = QString(eventID.c_str()).toHtmlEscaped(); }
140 
144  void updateText();
145 private:
146 
147  QString text_;
148  QString shortText_;
149  QColor color_;
150  sev_code_t sev_;
151  QString host_;
152  QString cat_;
153  QString app_;
154  timeval time_;
155  size_t seq_;
156  static size_t sequence;
157 
158  QString msg_;
159  QString application_;
160  QString pid_;
161  QString hostaddr_;
162  QString file_;
163  QString line_;
164  QString module_;
165  QString eventID_;
166  QString sourceType_;
167  int sourceSequence_;
168 };
169 
173 typedef std::list<qt_mf_msg> msgs_t;
174 
179 {
180 public:
181 
186  msg_iter_t(msgs_t::iterator it)
187  {
188  iter_ = it;
189  seq_ = it->seq();
190  }
191 
197  bool operator==(msg_iter_t const& other) const
198  {
199  return seq_ == other.seq_;
200  }
201 
207  bool operator<(msg_iter_t const& other) const
208  {
209  return seq_ < other.seq_;
210  }
211 
216  msgs_t::iterator get() const { return iter_; };
217 
218 
219 private:
220 
221  msgs_t::iterator iter_;
222  size_t seq_;
223 };
224 
228 typedef std::list<msg_iter_t> msg_iters_t;
232 typedef std::map<QString, msg_iters_t> msg_iters_map_t;
233 
234 #endif
QString const & app() const
Get the application of the message
Definition: qt_mf_msg.hh:86
void updateText()
Parse fields and create HTML string representing message
Definition: qt_mf_msg.cc:62
void setEventID(std::string eventID)
Set the Event ID of the message
Definition: qt_mf_msg.hh:139
timeval time() const
Get the message timestamp
Definition: qt_mf_msg.hh:91
size_t seq() const
Get the sequence number of the message
Definition: qt_mf_msg.hh:96
void setFileName(std::string file)
Set the file name field
Definition: qt_mf_msg.hh:124
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:71
void setSeverityLevel(sev_code_t sev)
Set the severity code of the message (Viewer levels)
Definition: qt_mf_msg.hh:107
msg_iter_t(msgs_t::iterator it)
Construct a msg_iter_t
Definition: qt_mf_msg.hh:186
QString const & host() const
Get the host from which the message came
Definition: qt_mf_msg.hh:76
void setMessage(std::string prefix, int iteration, std::string msg)
Set the message
Definition: qt_mf_msg.cc:55
bool operator<(msg_iter_t const &other) const
Comparison operator, based on message sequence number
Definition: qt_mf_msg.hh:207
Iterator for the msgs_t type
Definition: qt_mf_msg.hh:178
qt_mf_msg()
Default message constructor.
Definition: qt_mf_msg.hh:51
void setSeverity(mf::ELseverityLevel sev)
Set the Severity of the message (MF levels)
Definition: qt_mf_msg.cc:25
void setHostAddr(std::string hostaddr)
Set the hostaddr field
Definition: qt_mf_msg.hh:119
QString const & text(bool mode) const
Get the text of the message
Definition: qt_mf_msg.hh:61
void setLineNumber(std::string line)
Set the line number field
Definition: qt_mf_msg.hh:129
QString const & cat() const
Get the category of the message
Definition: qt_mf_msg.hh:81
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:197
void setModule(std::string module)
Set the module name
Definition: qt_mf_msg.hh:134
QColor const & color() const
Get the severity-based color of the message
Definition: qt_mf_msg.hh:66