00001 #ifndef MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
00002 #define MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
00003
00004
00005
00006
00007 #include <QtCore/QString>
00008 #include <QtGui/QColor>
00009
00010 #include <string>
00011 #include <vector>
00012 #include <list>
00013 #include <map>
00014
00015 #include <sys/time.h>
00016
00017 namespace mf
00018 {
00019 class MessageFacilityMsg;
00020 }
00021
00025 enum sev_code_t
00026 {
00027 SDEBUG,
00028 SINFO,
00029 SWARNING,
00030 SERROR
00031 };
00032
00036 class qt_mf_msg
00037 {
00038 public:
00043 explicit qt_mf_msg(mf::MessageFacilityMsg const& msg);
00044
00045
00051 QString const& text(bool mode) const { return mode ? shortText_ : text_; }
00056 QColor const& color() const { return color_; }
00061 sev_code_t sev() const { return sev_; }
00066 QString const& host() const { return host_; }
00071 QString const& cat() const { return cat_; }
00076 QString const& app() const { return app_; }
00081 timeval time() const { return time_; }
00086 size_t seq() const { return seq_; }
00087
00088 private:
00089
00090 QString text_;
00091 QString shortText_;
00092 QColor color_;
00093 sev_code_t sev_;
00094 QString host_;
00095 QString cat_;
00096 QString app_;
00097 timeval time_;
00098 size_t seq_;
00099 static size_t sequence;
00100 };
00101
00105 typedef std::list<qt_mf_msg> msgs_t;
00106
00110 class msg_iter_t
00111 {
00112 public:
00113
00118 msg_iter_t(msgs_t::iterator it)
00119 {
00120 iter_ = it;
00121 seq_ = it->seq();
00122 }
00123
00129 bool operator==(msg_iter_t const& other) const
00130 {
00131 return seq_ == other.seq_;
00132 }
00133
00139 bool operator<(msg_iter_t const& other) const
00140 {
00141 return seq_ < other.seq_;
00142 }
00143
00148 msgs_t::iterator get() const { return iter_; };
00149
00150
00151 private:
00152
00153 msgs_t::iterator iter_;
00154 size_t seq_;
00155 };
00156
00160 typedef std::list<msg_iter_t> msg_iters_t;
00164 typedef std::map<QString, msg_iters_t> msg_iters_map_t;
00165
00166 #endif