logs_table_model.hpp
Go to the documentation of this file.
00001 #ifndef LOGSTABLEMODEL_HPP
00002 #define LOGSTABLEMODEL_HPP
00003 
00004 #include <QAbstractTableModel>
00005 #include <QString>
00006 #include <QDateTime>
00007 #include <rosgraph_msgs/Log.h>
00008 #include <rosbag/view.h>
00009 #include <boost/circular_buffer.hpp>
00010 #include <unordered_map>
00011 #include <chrono>
00012 
00013 typedef std::chrono::high_resolution_clock::time_point TimePoint;
00014 
00015 
00016 class LogsTableModel : public QAbstractTableModel
00017 {
00018   Q_OBJECT
00019 
00020 public:
00021   explicit LogsTableModel(QObject *parent = 0);
00022 
00023   typedef enum{
00024     DEBUG = 0,
00025     INFO = 1,
00026     WARNINGS = 2,
00027     ERROR = 3
00028   }Severity;
00029 
00030   // Header:
00031   QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
00032 
00033   // Basic functionality:
00034   int rowCount(const QModelIndex &parent = QModelIndex()) const override;
00035 
00036   int columnCount(const QModelIndex &parent = QModelIndex()) const override;
00037 
00038   QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
00039 
00040   void push_back(const rosgraph_msgs::Log::ConstPtr& pushed_log);
00041 
00042   void push_back(const std::vector<rosgraph_msgs::Log::ConstPtr>& pushed_logs);
00043 
00044   const QString& message(int index) const;
00045 
00046   const QString &nodeName(int index) const;
00047 
00048   Severity severity(int index) const;
00049 
00050   TimePoint timestamp(int index) const;
00051 
00052   int size() const { return _logs.size(); }
00053 
00054   void clear();
00055 
00056 private:
00057 
00058   std::set<QString> _source_list;
00059   std::set<QString> _node_list;
00060 
00061   typedef struct{
00062     size_t count;
00063     int64_t time_usec_since_epoch;
00064     QString  time_text;
00065     Severity level_raw;
00066     const QString* node;
00067     QString message;
00068     const QString* source;
00069   }LogItem;
00070 
00071   boost::circular_buffer<LogItem> _logs;
00072 
00073   size_t _count;
00074 
00075   enum{ MAX_CAPACITY = 20000 }; // max capacity of the circular buffer
00076 
00077   LogItem convertRosout(const rosgraph_msgs::Log &log);
00078 
00079 #ifdef USE_ROSOUT2
00080   LogItem convertRosout(const rosout2_msg::LogMsg &log);
00081 #endif
00082 
00083 signals:
00084 
00085   void rowsShifted(int);
00086 
00087 };
00088 
00089 
00090 #endif // LOGSTABLEMODEL_HPP


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:04