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


plotjuggler_ros
Author(s): Davide Faconti
autogenerated on Fri Jun 23 2023 02:28:03