log_database.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2015, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef SWRI_CONSOLE_LOG_DATABASE_H_
32 #define SWRI_CONSOLE_LOG_DATABASE_H_
33 
34 #include <QObject>
35 #include <QAbstractListModel>
36 #include <QStringList>
37 #include <rosgraph_msgs/Log.h>
38 #include <deque>
39 #include <ros/time.h>
40 
41 namespace swri_console
42 {
43 struct LogEntry
44 {
46  uint8_t level;
47  std::string node;
48  std::string file;
49  std::string function;
50  uint32_t line;
51  QStringList text;
52  uint32_t seq;
53 };
54 
55 class LogDatabase : public QObject
56 {
57  Q_OBJECT
58 
59 public:
60  LogDatabase();
61  ~LogDatabase();
62 
63  void clear();
64  const std::deque<LogEntry>& log() { return log_; }
65  const ros::Time& minTime() const { return min_time_; }
66 
67  const std::map<std::string, size_t>& messageCounts() const { return msg_counts_; }
68 
69  Q_SIGNALS:
70  void databaseCleared();
71  void messagesAdded();
72  void minTimeUpdated();
73 
74 public Q_SLOTS:
75  void queueMessage(const rosgraph_msgs::LogConstPtr msg);
76  void processQueue();
77 
78 private:
79  std::map<std::string, size_t> msg_counts_;
80  std::deque<LogEntry> log_;
81  std::deque<LogEntry> new_msgs_;
82 
84 }; // class LogDatabase
85 } // namespace swri_console
86 #endif // SWRI_CONSOLE_LOG_DATABASE_H_
const ros::Time & minTime() const
Definition: log_database.h:65
std::deque< LogEntry > new_msgs_
Definition: log_database.h:81
const std::deque< LogEntry > & log()
Definition: log_database.h:64
std::deque< LogEntry > log_
Definition: log_database.h:80
const std::map< std::string, size_t > & messageCounts() const
Definition: log_database.h:67
std::map< std::string, size_t > msg_counts_
Definition: log_database.h:79


swri_console
Author(s):
autogenerated on Wed Jun 5 2019 21:25:59