00001 #include "rqt_mrta/config/application/application.h" 00002 00003 namespace rqt_mrta 00004 { 00005 namespace config 00006 { 00007 namespace application 00008 { 00009 Application::Application(QObject *parent) 00010 : AbstractConfig(parent), robots_(new Robots(this)) 00011 { 00012 connect(robots_, SIGNAL(changed()), this, SIGNAL(changed())); 00013 } 00014 00015 Application::~Application() 00016 { 00017 if (robots_) 00018 { 00019 delete robots_; 00020 robots_ = NULL; 00021 } 00022 } 00023 00024 QString Application::getName() const 00025 { 00026 return name_; 00027 } 00028 00029 QString Application::getArchitecturePackage() const 00030 { 00031 return architecture_; 00032 } 00033 00034 Robots *Application::getRobots() const 00035 { 00036 return robots_; 00037 } 00038 00039 void Application::setName(const QString &name) 00040 { 00041 if (name != name_) 00042 { 00043 name_ = name; 00044 emit nameChanged(name); 00045 emit changed(); 00046 } 00047 } 00048 00049 void Application::setArchitecturePackage(const QString &package) 00050 { 00051 if (package != architecture_) 00052 { 00053 architecture_ = package; 00054 emit architecturePackageChanged(package); 00055 emit changed(); 00056 } 00057 } 00058 00059 void Application::save(QSettings &settings) const 00060 { 00061 settings.beginGroup("application"); 00062 settings.setValue("name", name_); 00063 settings.setValue("architecture", architecture_); 00064 robots_->save(settings); 00065 settings.endGroup(); 00066 } 00067 00068 void Application::load(QSettings &settings) 00069 { 00070 settings.beginGroup("application"); 00071 setName(settings.value("name").toString()); 00072 setArchitecturePackage(settings.value("architecture").toString()); 00073 robots_->load(settings); 00074 settings.endGroup(); 00075 } 00076 00077 void Application::reset() 00078 { 00079 setName(""); 00080 setArchitecturePackage(""); 00081 robots_->reset(); 00082 } 00083 00084 void Application::write(QDataStream &stream) const 00085 { 00086 stream << name_; 00087 stream << architecture_; 00088 robots_->write(stream); 00089 } 00090 00091 void Application::read(QDataStream &stream) 00092 { 00093 QString name, architecture; 00094 stream >> name; 00095 setName(name); 00096 stream >> architecture; 00097 setArchitecturePackage(architecture); 00098 robots_->read(stream); 00099 } 00100 00101 Application &Application::operator=(const Application &config) 00102 { 00103 setName(config.name_); 00104 setArchitecturePackage(config.architecture_); 00105 return *this; 00106 } 00107 } 00108 } 00109 }