logs_table_model.hpp
Go to the documentation of this file.
1 #ifndef LOGSTABLEMODEL_HPP
2 #define LOGSTABLEMODEL_HPP
3 
4 #include <QAbstractTableModel>
5 #include <QString>
6 #include <QDateTime>
7 #include <rosgraph_msgs/Log.h>
8 #include <rosbag/view.h>
9 #include <boost/circular_buffer.hpp>
10 #include <unordered_map>
11 #include <chrono>
12 
13 typedef std::chrono::high_resolution_clock::time_point TimePoint;
14 
15 
16 class LogsTableModel : public QAbstractTableModel
17 {
18  Q_OBJECT
19 
20 public:
21  explicit LogsTableModel(QObject *parent = 0);
22 
23  typedef enum{
24  DEBUG = 0,
25  INFO = 1,
26  WARNINGS = 2,
27  ERROR = 3
28  }Severity;
29 
30  // Header:
31  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
32 
33  // Basic functionality:
34  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
35 
36  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
37 
38  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
39 
40  void push_back(const rosgraph_msgs::Log::ConstPtr& pushed_log);
41 
42  void push_back(const std::vector<rosgraph_msgs::Log::ConstPtr>& pushed_logs);
43 
44  const QString& message(int index) const;
45 
46  const QString &nodeName(int index) const;
47 
48  Severity severity(int index) const;
49 
50  TimePoint timestamp(int index) const;
51 
52  int size() const { return _logs.size(); }
53 
54  void clear();
55 
56 private:
57 
58  std::set<QString> _source_list;
59  std::set<QString> _node_list;
60 
61  typedef struct{
62  size_t count;
64  QString time_text;
66  const QString* node;
67  QString message;
68  const QString* source;
69  }LogItem;
70 
71  boost::circular_buffer<LogItem> _logs;
72 
73  size_t _count;
74 
75  enum{ MAX_CAPACITY = 20000 }; // max capacity of the circular buffer
76 
77  LogItem convertRosout(const rosgraph_msgs::Log &log);
78 
79 #ifdef USE_ROSOUT2
80  LogItem convertRosout(const rosout2_msg::LogMsg &log);
81 #endif
82 
83 signals:
84 
85  void rowsShifted(int);
86 
87 };
88 
89 
90 #endif // LOGSTABLEMODEL_HPP
int columnCount(const QModelIndex &parent=QModelIndex()) const override
LogItem convertRosout(const rosgraph_msgs::Log &log)
std::chrono::high_resolution_clock::time_point TimePoint
TimePoint timestamp(int index) const
LogsTableModel(QObject *parent=0)
void rowsShifted(int)
std::set< QString > _node_list
const QString & message(int index) const
boost::circular_buffer< LogItem > _logs
std::set< QString > _source_list
Severity severity(int index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool log
const QString & nodeName(int index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void push_back(const rosgraph_msgs::Log::ConstPtr &pushed_log)
int size() const


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17