Go to the documentation of this file.00001 #include "mrta/task.h"
00002 #include "rqt_mrta/config/application/task.h"
00003
00004 namespace mrta
00005 {
00006 Task::Task(QObject* parent) : QObject(parent), config_(NULL) {}
00007
00008 Task::Task(QObject* parent, Task::Config* config)
00009 : QObject(parent), config_(NULL)
00010 {
00011 setConfig(config);
00012 }
00013
00014 Task::Task(const Task& task)
00015 : QObject(task.parent()), config_(NULL), id_(task.id_)
00016 {
00017 setConfig(task.config_);
00018 }
00019
00020 Task::~Task() {
00021 config_ = NULL;
00022 ROS_INFO_STREAM("[~Task]");
00023 }
00024
00025 Task::Config* Task::getConfig() const { return config_; }
00026
00027 void Task::setConfig(Task::Config* config)
00028 {
00029 if (config != config_)
00030 {
00031 if (config_)
00032 {
00033 disconnect(config_, SIGNAL(changed()), this, SIGNAL(changed()));
00034 disconnect(config_, SIGNAL(destroyed()), this, SLOT(configDestroyed()));
00035 disconnect(config_, SIGNAL(idChanged(const QString&)), this,
00036 SLOT(setId(const QString&)));
00037 }
00038 config_ = config;
00039 if (config_)
00040 {
00041 connect(config_, SIGNAL(changed()), this, SIGNAL(changed()));
00042 connect(config_, SIGNAL(destroyed()), this, SLOT(configDestroyed()));
00043 connect(config_, SIGNAL(idChanged(const QString&)), this,
00044 SLOT(setId(const QString&)));
00045 setId(config_->getId());
00046 }
00047 }
00048 }
00049
00050 QString Task::getId() const { return id_; }
00051
00052 void Task::setId(const QString& id)
00053 {
00054 if (id != id_)
00055 {
00056 id_ = id;
00057 emit idChanged(id);
00058 emit changed();
00059 }
00060 }
00061
00062 Task& Task::operator=(const Task& task)
00063 {
00064 id_ = task.id_;
00065 emit changed();
00066 }
00067
00068 void Task::configDestroyed() { config_ = NULL; }
00069 }