Go to the documentation of this file.00001 #include "rqt_mrta/config/architecture/robots.h"
00002
00003 namespace rqt_mrta
00004 {
00005 namespace config
00006 {
00007 namespace architecture
00008 {
00009 Robots::Robots(QObject* parent)
00010 : AbstractConfig(parent), busy_robots_(new BusyRobots(this)),
00011 idle_robots_(new IdleRobots(this))
00012 {
00013 connect(busy_robots_, SIGNAL(changed()), this, SIGNAL(changed()));
00014 connect(idle_robots_, SIGNAL(changed()), this, SIGNAL(changed()));
00015 }
00016
00017 Robots::~Robots()
00018 {
00019 if (busy_robots_)
00020 {
00021 delete busy_robots_;
00022 busy_robots_ = NULL;
00023 }
00024 if (idle_robots_)
00025 {
00026 delete idle_robots_;
00027 idle_robots_ = NULL;
00028 }
00029 }
00030
00031 QString Robots::getType() const { return type_; }
00032
00033 QString Robots::getConfigId() const { return config_id_; }
00034
00035 QString Robots::getLaunchId() const { return launch_id_; }
00036
00037 BusyRobots* Robots::getBusyRobots() const { return busy_robots_; }
00038
00039 IdleRobots* Robots::getIdleRobots() const { return idle_robots_; }
00040
00041 void Robots::setType(const QString& type)
00042 {
00043 if (type != type_)
00044 {
00045 type_ = type;
00046 emit typeChanged(type);
00047 emit changed();
00048 }
00049 }
00050
00051 void Robots::setConfigId(const QString& config_id)
00052 {
00053 if (config_id != config_id_)
00054 {
00055 config_id_ = config_id;
00056 emit configIdChanged(config_id);
00057 emit changed();
00058 }
00059 }
00060
00061 void Robots::setLaunchId(const QString& launch_id)
00062 {
00063 if (launch_id != launch_id_)
00064 {
00065 launch_id_ = launch_id;
00066 emit launchIdChanged(launch_id);
00067 emit changed();
00068 }
00069 }
00070
00071 void Robots::save(QSettings& settings) const
00072 {
00073 settings.beginGroup("robots");
00074 settings.setValue("type", type_);
00075 settings.setValue("config_id", config_id_);
00076 settings.setValue("launch_id", launch_id_);
00077 busy_robots_->save(settings);
00078 idle_robots_->save(settings);
00079 settings.endGroup();
00080 }
00081
00082 void Robots::load(QSettings& settings)
00083 {
00084 settings.beginGroup("robots");
00085 setType(settings.value("type").toString());
00086 setConfigId(settings.value("config_id").toString());
00087 setLaunchId(settings.value("launch_id").toString());
00088 busy_robots_->load(settings);
00089 idle_robots_->load(settings);
00090 settings.endGroup();
00091 }
00092
00093 void Robots::reset()
00094 {
00095 setType("");
00096 setConfigId("");
00097 setLaunchId("");
00098 busy_robots_->reset();
00099 idle_robots_->reset();
00100 }
00101
00102 void Robots::write(QDataStream& stream) const
00103 {
00104 stream << type_;
00105 stream << config_id_;
00106 stream << launch_id_;
00107 busy_robots_->write(stream);
00108 idle_robots_->write(stream);
00109 }
00110
00111 void Robots::read(QDataStream& stream)
00112 {
00113 QString type;
00114 stream >> type;
00115 setType(type);
00116 QString config_id;
00117 stream >> config_id;
00118 setConfigId(config_id);
00119 QString launch_id;
00120 stream >> launch_id;
00121 setLaunchId(launch_id);
00122 busy_robots_->read(stream);
00123 idle_robots_->read(stream);
00124 }
00125
00126 Robots& Robots::operator=(const Robots& config)
00127 {
00128 setType(config.type_);
00129 setConfigId(config.config_id_);
00130 setLaunchId(config.launch_id_);
00131 *busy_robots_ = *config.busy_robots_;
00132 *idle_robots_ = *config.idle_robots_;
00133 return *this;
00134 }
00135 }
00136 }
00137 }