LCOV - code coverage report
Current view: top level - /opt/artdaq/srcs/artdaq-mfextensions/mfextensions/Receivers - qt_mf_msg.hh (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 16 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 17 0

            Line data    Source code
       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 <list>
      11              : #include <map>
      12              : #include <memory>
      13              : #include <string>
      14              : #include <vector>
      15              : 
      16              : #include <sys/time.h>
      17              : #include "messagefacility/Utilities/ELseverityLevel.h"
      18              : 
      19              : namespace mf {
      20              : class ErrorObj;
      21              : }
      22              : 
      23              : /// <summary>
      24              : /// Severity codes enumeration for internal use
      25              : /// </summary>
      26              : enum sev_code_t
      27              : {
      28              :         SDEBUG,
      29              :         SINFO,
      30              :         SWARNING,
      31              :         SERROR
      32              : };
      33              : 
      34              : /// <summary>
      35              : /// Qt wrapper around MessageFacility message
      36              : /// </summary>
      37              : class qt_mf_msg
      38              : {
      39              : public:
      40              :         /// <summary>
      41              :         /// Construct a qt_mf_msg
      42              :         /// </summary>
      43              :         /// <param name="hostname">Hostname of the message source</param>
      44              :         /// <param name="category">Category of the message</param>
      45              :         /// <param name="application">Application of the message</param>
      46              :         /// <param name="pid">PID of the message</param>
      47              :         /// <param name="time">Timestamp of the message</param>
      48              :         qt_mf_msg(const std::string& hostname, const std::string& category, const std::string& application, pid_t pid, timeval time);
      49              : 
      50              :         /// Default message constructor
      51            0 :         qt_mf_msg() {}
      52              :         /// Default copy constructor
      53            0 :         qt_mf_msg(const qt_mf_msg&) = default;
      54              :         qt_mf_msg(qt_mf_msg&&) = default;                  ///< Default Move Constructor
      55            0 :         qt_mf_msg& operator=(qt_mf_msg const&) = default;  ///< Default Copy Assignment Operator
      56              :         qt_mf_msg& operator=(qt_mf_msg&&) = default;       ///< Default Move Assignment Operator
      57              : 
      58            0 :         virtual ~qt_mf_msg() = default;  ///< Default Destructor
      59              : 
      60              :         // get method
      61              :         /// <summary>
      62              :         /// Get the text of the message
      63              :         /// </summary>
      64              :         /// <param name="mode">Whether to return the short-form text</param>
      65              :         /// <returns>Text of the message</returns>
      66            0 :         QString const& text(bool mode) const { return mode ? shortText_ : text_; }
      67              :         /// <summary>
      68              :         /// Get the severity-based color of the message
      69              :         /// </summary>
      70              :         /// <returns>Color of the message</returns>
      71              :         QColor const& color() const { return color_; }
      72              :         /// <summary>
      73              :         /// Get the severity of the message
      74              :         /// </summary>
      75              :         /// <returns>Message severity</returns>
      76            0 :         sev_code_t sev() const { return sev_; }
      77              :         /// <summary>
      78              :         /// Get the host from which the message came
      79              :         /// </summary>
      80              :         /// <returns>Hostname of message</returns>
      81            0 :         QString const& host() const { return host_; }
      82              :         /// <summary>
      83              :         /// Get the category of the message
      84              :         /// </summary>
      85              :         /// <returns>Message category</returns>
      86            0 :         QString const& cat() const { return cat_; }
      87              :         /// <summary>
      88              :         /// Get the application of the message
      89              :         /// </summary>
      90              :         /// <returns>Message application</returns>
      91            0 :         QString const& app() const { return app_; }
      92              :         /// <summary>
      93              :         /// Get the message timestamp
      94              :         /// </summary>
      95              :         /// <returns>Timestamp of the message</returns>
      96            0 :         timeval time() const { return time_; }
      97              :         /// <summary>
      98              :         /// Get the sequence number of the message
      99              :         /// </summary>
     100              :         /// <returns>Message sequence number</returns>
     101              :         size_t seq() const { return seq_; }
     102              : 
     103              :         /// <summary>
     104              :         /// Set the Severity of the message (MF levels)
     105              :         /// </summary>
     106              :         /// <param name="sev">Severity level of the message</param>
     107              :         void setSeverity(mf::ELseverityLevel sev);
     108              :         /// <summary>
     109              :         /// Set the severity code of the message (Viewer levels)
     110              :         /// </summary>
     111              :         /// <param name="sev">Severity code of the message</param>
     112            0 :         void setSeverityLevel(sev_code_t sev) { sev_ = sev; }
     113              :         /// <summary>
     114              :         /// Set the message
     115              :         /// </summary>
     116              :         /// <param name="prefix">Message prefix</param>
     117              :         /// <param name="iteration">Message iteration (run/event no)</param>
     118              :         /// <param name="msg">Message text</param>
     119              :         void setMessage(const std::string& prefix, int iteration, const std::string& msg);
     120              :         /// <summary>
     121              :         /// Set the hostaddr field
     122              :         /// </summary>
     123              :         /// <param name="hostaddr">Host address of message source</param>
     124            0 :         void setHostAddr(std::string const& hostaddr) { hostaddr_ = QString(hostaddr.c_str()).toHtmlEscaped(); }
     125              :         /// <summary>
     126              :         /// Set the file name field
     127              :         /// </summary>
     128              :         /// <param name="file">File generating message</param>
     129            0 :         void setFileName(std::string const& file) { file_ = QString(file.c_str()).toHtmlEscaped(); }
     130              :         /// <summary>
     131              :         /// Set the line number field
     132              :         /// </summary>
     133              :         /// <param name="line">Line number in file</param>
     134            0 :         void setLineNumber(std::string const& line) { line_ = QString(line.c_str()).toHtmlEscaped(); }
     135              :         /// <summary>
     136              :         /// Set the module name
     137              :         /// </summary>
     138              :         /// <param name="module">Module generating message</param>
     139            0 :         void setModule(std::string const& module) { module_ = QString(module.c_str()).toHtmlEscaped(); }
     140              :         /// <summary>
     141              :         /// Set the Event ID of the message
     142              :         /// </summary>
     143              :         /// <param name="eventID">Event ID to set</param>
     144            0 :         void setEventID(std::string const& eventID) { eventID_ = QString(eventID.c_str()).toHtmlEscaped(); }
     145              : 
     146              :         /// <summary>
     147              :         /// Parse fields and create HTML string representing message
     148              :         /// </summary>
     149              :         void updateText();
     150              : 
     151              : private:
     152              :         QString text_;
     153              :         QString shortText_;
     154              :         QColor color_;
     155              :         sev_code_t sev_;
     156              :         QString host_;
     157              :         QString cat_;
     158              :         QString app_;
     159              :         timeval time_;
     160              :         size_t seq_;
     161              :         static size_t sequence;
     162              : 
     163              :         QString msg_;
     164              :         QString application_;
     165              :         QString pid_;
     166              :         QString hostaddr_;
     167              :         QString file_;
     168              :         QString line_;
     169              :         QString module_;
     170              :         QString eventID_;
     171              :         QString sourceType_;
     172              :         int sourceSequence_;
     173              : };
     174              : 
     175              : /// <summary>
     176              : /// A std::shared_ptr to a qt_mf_msg
     177              : /// </summary>
     178              : typedef std::shared_ptr<qt_mf_msg> msg_ptr_t;
     179              : 
     180              : /// <summary>
     181              : /// A std::list of msg_ptr_t
     182              : /// </summary>
     183              : typedef std::list<msg_ptr_t> msgs_t;
     184              : 
     185              : /// <summary>
     186              : /// A std::map relating a QString and a msgs_t
     187              : /// </summary>
     188              : typedef std::map<QString, msgs_t> msgs_map_t;
     189              : 
     190              : #endif
        

Generated by: LCOV version 2.0-1