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_
swri_console::LogDatabase::messageCounts
const std::map< std::string, size_t > & messageCounts() const
Definition: log_database.h:67
swri_console::LogDatabase::clear
void clear()
Definition: log_database.cpp:45
swri_console::LogDatabase::new_msgs_
std::deque< LogEntry > new_msgs_
Definition: log_database.h:81
swri_console::LogDatabase::processQueue
void processQueue()
Definition: log_database.cpp:74
swri_console::LogDatabase::databaseCleared
void databaseCleared()
swri_console::LogEntry::seq
uint32_t seq
Definition: log_database.h:52
time.h
swri_console::LogDatabase::messagesAdded
void messagesAdded()
swri_console::LogEntry::node
std::string node
Definition: log_database.h:47
swri_console::LogDatabase::queueMessage
void queueMessage(const rosgraph_msgs::LogConstPtr msg)
Definition: log_database.cpp:53
swri_console::LogDatabase::min_time_
ros::Time min_time_
Definition: log_database.h:83
swri_console::LogEntry::file
std::string file
Definition: log_database.h:48
swri_console::LogDatabase::log_
std::deque< LogEntry > log_
Definition: log_database.h:80
swri_console::LogEntry
Definition: log_database.h:43
swri_console::LogDatabase
Definition: log_database.h:55
swri_console::LogEntry::line
uint32_t line
Definition: log_database.h:50
swri_console::LogDatabase::minTimeUpdated
void minTimeUpdated()
swri_console::LogDatabase::~LogDatabase
~LogDatabase()
Definition: log_database.cpp:41
swri_console::LogEntry::stamp
ros::Time stamp
Definition: log_database.h:45
swri_console
Definition: bag_reader.h:40
ros::Time
swri_console::LogEntry::text
QStringList text
Definition: log_database.h:51
console_generator.msg
msg
Definition: console_generator.py:58
swri_console::LogDatabase::minTime
const ros::Time & minTime() const
Definition: log_database.h:65
swri_console::LogDatabase::msg_counts_
std::map< std::string, size_t > msg_counts_
Definition: log_database.h:79
swri_console::LogDatabase::LogDatabase
LogDatabase()
Definition: log_database.cpp:35
swri_console::LogDatabase::log
const std::deque< LogEntry > & log()
Definition: log_database.h:64
swri_console::LogEntry::level
uint8_t level
Definition: log_database.h:46


swri_console
Author(s): P. J. Reed , Jerry Towler , David Anthony
autogenerated on Sat Sep 23 2023 02:55:36