00001 #ifndef _RQT_MRTA_CONFIG_CONFIG_H_ 00002 #define _RQT_MRTA_CONFIG_CONFIG_H_ 00003 00004 #include <QMap> 00005 #include <QVector> 00006 #include "rqt_mrta/config/param_interface.h" 00007 00008 namespace rqt_mrta 00009 { 00010 namespace config 00011 { 00012 class Param; 00013 class ParamInterface; 00014 class Params; 00015 class ParamsArray; 00016 00017 class Config : public utilities::AbstractConfig 00018 { 00019 Q_OBJECT 00020 public: 00021 Config(QObject* parent = NULL); 00022 virtual ~Config(); 00023 QString getId() const; 00024 void setId(const QString& id); 00025 QVector<ParamInterface*> getChildren() const; 00026 ParamInterface* getChild(size_t index) const; 00027 ParamInterface* getParam(const QString& relative_name) const; 00028 void addParam(ParamInterface* param); 00029 void removeParam(const QString& full_name); 00030 void clearParams(); 00031 void clearParams(const QString& full_name); 00032 bool contains(const QString& full_name) const; 00033 size_t count() const; 00034 size_t count(const QString& full_name) const; 00035 bool isEmpty() const; 00036 bool isEmpty(const QString& full_name) const; 00037 void save(QSettings& settings) const; 00038 void load(QSettings& settings); 00039 void reset(); 00040 void write(QDataStream& stream) const; 00041 void read(QDataStream& stream); 00042 Config& operator=(const Config& config); 00043 QString validate() const; 00044 void saveAsYaml(const QString& url) const; 00045 void hideArrays(); 00046 00047 signals: 00048 void idChanged(const QString& id); 00049 void added(const QString& full_name); 00050 void removed(const QString& full_name); 00051 void cleared(const QString& full_name); 00052 void nameChanged(const QString& previous_name, const QString& name); 00053 void typeChanged(const QString& name, const QMetaType::Type& type); 00054 void valueChanged(const QString& name, const QVariant& value); 00055 void defaultValueChanged(const QString& name, const QVariant& default_value); 00056 void toolTipChanged(const QString& name, const QString& tool_tip); 00057 00058 private: 00059 typedef QMap<Param*, ParamsArray*> ArrayMap; 00060 typedef ArrayMap::iterator iterator; 00061 typedef ArrayMap::const_iterator const_iterator; 00062 QString id_; 00063 QVector<ParamInterface*> params_; 00064 ArrayMap arrays_; 00065 void findArrays(Params *parent); 00066 void clearArrays(); 00067 QString toYaml() const; 00068 00069 private slots: 00070 void paramDestroyed(); 00071 void arraySizeChanged(const QString& full_name, const QVariant& value); 00072 }; 00073 } 00074 } 00075 00076 #endif // _RQT_MRTA_CONFIG_CONFIG_H_