Go to the documentation of this file.00001 #include "rqt_mrta/config/architecture/topic.h"
00002
00003 namespace rqt_mrta
00004 {
00005 namespace config
00006 {
00007 namespace architecture
00008 {
00009 Topic::Topic(QObject* parent) : AbstractConfig(parent) {}
00010
00011 Topic::~Topic() {}
00012
00013 QString Topic::getName() const { return name_; }
00014
00015 QString Topic::getType() const { return type_; }
00016
00017 size_t Topic::getQueueSize() const { return queue_size_; }
00018
00019 QString Topic::getField() const { return field_; }
00020
00021 ros::Duration Topic::getTimeout() const { return timeout_; }
00022
00023 ros::Duration Topic::getHorizon() const { return horizon_; }
00024
00025 void Topic::setName(const QString& name)
00026 {
00027 if (name != name_)
00028 {
00029 name_ = name;
00030 emit nameChanged(name);
00031 emit changed();
00032 }
00033 }
00034
00035 void Topic::setType(const QString& type)
00036 {
00037 if (type != type_)
00038 {
00039 type_ = type;
00040 emit typeChanged(type);
00041 emit changed();
00042 }
00043 }
00044
00045 void Topic::setQueueSize(const size_t& queue_size)
00046 {
00047 if (queue_size != queue_size_)
00048 {
00049 queue_size_ = queue_size;
00050 emit queueSizeChanged(queue_size);
00051 emit changed();
00052 }
00053 }
00054
00055 void Topic::setField(const QString& field)
00056 {
00057 if (field != field_)
00058 {
00059 field_ = field;
00060 emit fieldChanged(field);
00061 emit changed();
00062 }
00063 }
00064
00065 void Topic::setTimeout(const ros::Duration& timeout)
00066 {
00067 if (timeout != timeout_)
00068 {
00069 timeout_ = timeout;
00070 emit timeoutChanged(timeout);
00071 emit changed();
00072 }
00073 }
00074
00075 void Topic::setHorizon(const ros::Duration& horizon)
00076 {
00077 if (horizon != horizon_)
00078 {
00079 horizon_ = horizon;
00080 emit horizonChanged(horizon);
00081 emit changed();
00082 }
00083 }
00084
00085 void Topic::save(QSettings& settings) const
00086 {
00087 settings.beginGroup("topic");
00088 settings.setValue("name", name_);
00089 settings.setValue("type", type_);
00090 settings.setValue("queue_size", (quint64)queue_size_);
00091 settings.setValue("field", field_);
00092 settings.setValue("timeout", timeout_.toSec());
00093 settings.setValue("horizon", horizon_.toSec());
00094 settings.endGroup();
00095 }
00096
00097 void Topic::load(QSettings& settings)
00098 {
00099 settings.beginGroup("topic");
00100 setName(settings.value("name").toString());
00101 setType(settings.value("type").toString());
00102 setQueueSize(settings.value("queue_size").toULongLong());
00103 setField(settings.value("field").toString());
00104 setTimeout(ros::Duration(settings.value("timeout", 2.0).toDouble()));
00105 setHorizon(ros::Duration(settings.value("horizon", 5.0).toDouble()));
00106 settings.endGroup();
00107 }
00108
00109 void Topic::reset()
00110 {
00111 setName("");
00112 setType("");
00113 setQueueSize(10);
00114 setField("");
00115 setTimeout(ros::Duration(2.0));
00116 setHorizon(ros::Duration(5.0));
00117 }
00118
00119 void Topic::write(QDataStream& stream) const
00120 {
00121 stream << name_;
00122 stream << type_;
00123 stream << (quint64)queue_size_;
00124 stream << field_;
00125 stream << timeout_.toSec();
00126 stream << horizon_.toSec();
00127 }
00128
00129 void Topic::read(QDataStream& stream)
00130 {
00131 QString name, type, field;
00132 quint64 queue_size;
00133 double timeout, horizon;
00134 stream >> name;
00135 setName(name);
00136 stream >> type;
00137 setType(type);
00138 stream >> queue_size;
00139 setQueueSize(queue_size);
00140 stream >> field;
00141 setField(field);
00142 stream >> timeout;
00143 setTimeout(ros::Duration(timeout));
00144 stream >> horizon;
00145 setHorizon(ros::Duration(horizon));
00146 }
00147
00148 Topic& Topic::operator=(const Topic& config)
00149 {
00150 setName(config.name_);
00151 setType(config.type_);
00152 setQueueSize(config.queue_size_);
00153 setField(config.field_);
00154 setTimeout(config.timeout_);
00155 setHorizon(config.horizon_);
00156 return *this;
00157 }
00158 }
00159 }
00160 }