Go to the documentation of this file.00001 #include "mrta/history.h"
00002 #include <ros/console.h>
00003
00004 namespace mrta
00005 {
00006 History::History(QObject *parent) : QObject(parent) {}
00007
00008 History::~History()
00009 {
00010 ROS_INFO_STREAM("[~History] before");
00011 for (size_t index(0); index < logs_.count(); index++)
00012 {
00013 if (logs_[index])
00014 {
00015 delete logs_[index];
00016 logs_[index] = NULL;
00017 }
00018 }
00019 logs_.clear();
00020 ROS_INFO_STREAM("[~History] after");
00021 }
00022
00023 QList<Log*> History::getLogs() const { return logs_; }
00024
00025 void History::log(const ros::Time& timestamp, Log::Type type,
00026 Log::Severity severity, const QString& id, int state)
00027 {
00028 Log* log = new Log(this, timestamp, type, severity, id, state);
00029 switch (severity)
00030 {
00031 case Log::Debug:
00032 ROS_DEBUG("%s", log->toCString());
00033 break;
00034 case Log::Info:
00035 ROS_INFO("%s", log->toCString());
00036 break;
00037 case Log::Warn:
00038 ROS_WARN("%s", log->toCString());
00039 break;
00040 case Log::Error:
00041 ROS_ERROR("%s", log->toCString());
00042 break;
00043 case Log::Fatal:
00044 ROS_FATAL("%s", log->toCString());
00045 break;
00046 }
00047 logs_.append(log);
00048 }
00049 }