libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/p3d/ParametersEnv.hpp
00001 /*
00002  *  ParamtersEnv.h
00003  *  BioMove3D
00004  *
00005  *  Created by Jim Mainprice on 21/09/10.
00006  *  Copyright 2010 LAAS/CNRS. All rights reserved.
00007  *
00008  */
00009 
00010 #ifndef PARAMETERS_ENV_HPP
00011 #define PARAMETERS_ENV_HPP
00012 
00013 #ifdef QT_LIBRARY
00014 #undef CursorShape
00015 #include <QtCore/QObject>
00016 #endif
00017 
00018 #include <map>
00019 #include <utility>
00020 #include <string>
00021 #include <vector>
00022 
00023 // ---------------------------------------------------------------------------
00024 // Bool Containers
00025 // ---------------------------------------------------------------------------
00026 class boolContainer
00027 #ifdef QT_LIBRARY
00028 : public QObject
00029 #endif
00030 {
00031 #ifdef QT_LIBRARY
00032         Q_OBJECT;
00033 #endif
00034         bool _Value;
00035         
00036 public:
00037         boolContainer(bool v = false);
00038         bool get();
00039 #ifdef QT_LIBRARY
00040         public slots:
00041 #endif
00042         void set(bool v);
00043         
00044 #ifdef QT_LIBRARY
00045 signals:
00046 #endif
00047         void valueChanged(bool v);
00048 };
00049 
00050 // ---------------------------------------------------------------------------
00051 // Int Containers
00052 // ---------------------------------------------------------------------------
00053 class intContainer
00054 #ifdef QT_LIBRARY
00055 : public QObject
00056 #endif
00057 {
00058 #ifdef QT_LIBRARY
00059         Q_OBJECT;
00060 #endif
00061         int _Value;
00062         
00063 public:
00064         intContainer(int v = false);
00065         int get();
00066         
00067 #ifdef QT_LIBRARY
00068         public slots:
00069 #endif
00070         void set(int v);
00071         
00072 #ifdef QT_LIBRARY
00073 signals:
00074 #endif
00075         void valueChanged(int v);
00076 };
00077 
00078 // ---------------------------------------------------------------------------
00079 // Double Containers
00080 // ---------------------------------------------------------------------------
00081 class doubleContainer
00082 #ifdef QT_LIBRARY
00083 : public QObject
00084 #endif
00085 {
00086 #ifdef QT_LIBRARY
00087         Q_OBJECT;
00088 #endif
00089         double _Value;
00090         
00091 public:
00092         doubleContainer(double v = false);
00093         double get();
00094         
00095 #ifdef QT_LIBRARY
00096         public slots:
00097 #endif
00098         void set(double v);
00099         
00100 #ifdef QT_LIBRARY
00101 signals:
00102 #endif
00103         void valueChanged(double v);
00104 };
00105 
00106 // ---------------------------------------------------------------------------
00107 // String Containers
00108 // ---------------------------------------------------------------------------
00113 class stringContainer
00114 #ifdef QT_LIBRARY
00115 : public QObject
00116 #endif
00117 {
00118 #ifdef QT_LIBRARY
00119         Q_OBJECT;
00120         
00121         QString _Value;
00122         
00123 public:
00124         stringContainer(QString v = "");
00125         QString get();
00126         
00127         
00128         public slots:
00129         void set(QString v);
00130         
00131         
00132 signals:
00133         
00134         void valueChanged(QString v);
00135 #endif
00136 };
00137 
00138 // ---------------------------------------------------------------------------
00139 // Vector Containers
00140 // ---------------------------------------------------------------------------
00145 class vectorContainer
00146 #ifdef QT_LIBRARY
00147 : public QObject
00148 #endif
00149 {
00150 #ifdef QT_LIBRARY
00151         Q_OBJECT;
00152 #endif
00153         std::vector<double> _Value;
00154         
00155 public:
00156         vectorContainer() { }
00157         vectorContainer(std::vector<double>);
00158         std::vector<double> get();
00159         
00160 #ifdef QT_LIBRARY
00161         public slots:
00162 #endif
00163         void set(std::vector<double> v);
00164         
00165 #ifdef QT_LIBRARY
00166 signals:
00167 #endif
00168         void valueChanged(std::vector<double> v);
00169         
00170 };
00171 
00172 // ---------------------------------------------------------------------------
00173 // \brief Classe permettant de se lier à l'interface graphique
00174 // ---------------------------------------------------------------------------
00175 
00176 template <typename enumBool,
00177                                         typename enumInt,
00178                                         typename enumDouble,
00179                                         typename enumString,
00180                                         typename enumVector>
00181 class Parameters
00182 #ifdef QT_LIBRARY
00183 : public QObject
00184 #endif
00185 {
00186 public:
00187         
00188 //#ifdef QT_LIBRARY
00189 //      Q_OBJECT;
00190 //#endif
00191         
00192 public:
00196         Parameters(     std::map<enumBool,              boolContainer*>                         valuesBool,
00197                                                  std::map<enumInt,                      intContainer*>                          valuesInt,
00198                                                  std::map<enumDouble,           doubleContainer*>                       valuesDouble,
00199                                                  std::map<enumString,           stringContainer*>                       valuesString,
00200                                                  std::map<enumVector,           vectorContainer*>                       valuesVector )
00201                                                  :
00202                                                  mBoolMap(valuesBool),
00203                                                  mIntMap(valuesInt),
00204                                                  mDoubleMap(valuesDouble),
00205                                                  mStringMap(valuesString),
00206                                                  mVectorMap(valuesVector)
00207         {
00208                 
00209         }
00210         
00214         ~Parameters() { }
00215         
00216         bool getBool(enumBool p) {
00217                 return (mBoolMap[p]->get());
00218         }
00219         
00220         void setBool(enumBool p, bool v) {
00221                 mBoolMap[p]->set(v);
00222         }
00223         
00224         int getInt(enumInt p) {
00225                 return (mIntMap[p]->get());
00226         }
00227         
00228         void setInt(enumInt p, int v) {
00229                 mIntMap[p]->set(v);
00230         }
00231         
00232         double getDouble(enumDouble p) {
00233                 return (mDoubleMap[p]->get());
00234         }
00235         
00236         void setDouble(enumDouble p, double v) {
00237                 mDoubleMap[p]->set(v);
00238         }
00239         
00240         std::vector<double> getVector(enumVector p) {
00241                 return (mVectorMap[p]->get());
00242         }
00243         
00244         void setVector(enumVector p, std::vector<double> v) {
00245                 mVectorMap[p]->set(v);
00246         }
00247         
00248         
00249 #ifdef QT_LIBRARY
00250         QString getString(enumString p) {
00251                 return (mStringMap[p]->get());
00252         }
00253         
00254         void setString(enumString p, QString v) {
00255                 mStringMap[p]->set(v);
00256         }
00257         
00258         QObject* getObject(enumInt p) {
00259                 return (mIntMap[p]);
00260         }
00261         
00262         QObject* getObject(enumBool p) {
00263                 return (mBoolMap[p]);
00264         }
00265         
00266         QObject* getObject(enumDouble p) {
00267                 return (mDoubleMap[p]);
00268         }
00269         
00270         QObject* getObject(enumVector p) {
00271                 return (mVectorMap[p]);
00272         }
00273         
00274         QObject* getObject(enumString p) {
00275                 return (mStringMap[p]);
00276         }
00277 #endif
00278         
00282         typedef std::pair<enumBool,                                     boolContainer*>         boolMap_t;
00283         typedef std::pair<enumInt,                                      intContainer*>          intMap_t;
00284         typedef std::pair<enumDouble,                           doubleContainer*> doubleMap_t;
00285         typedef std::pair<enumString,                           stringContainer*> stringMap_t;
00286         typedef std::pair<enumVector,                           vectorContainer*> vectorMap_t;
00287         
00288         std::map<enumBool, boolContainer*>                              getBoolMap() {return mBoolMap; }
00289         std::map<enumInt, intContainer*>                                        getIntMap() {return mIntMap; }
00290         std::map<enumDouble, doubleContainer*>          getDoubleMap() {return mDoubleMap; }
00291         std::map<enumString, stringContainer*>          getStringMap() {return mStringMap; }
00292         std::map<enumVector, vectorContainer*>          getVectorMap() {return mVectorMap; }
00293         
00294 private:
00295         std::map<enumBool,              boolContainer*>                         mBoolMap;
00296         std::map<enumInt,                       intContainer*>                          mIntMap;
00297         std::map<enumDouble,    doubleContainer*>                       mDoubleMap;
00298         std::map<enumString,    stringContainer*>                       mStringMap;
00299         std::map<enumVector,    vectorContainer*>                       mVectorMap;
00300         
00301 };
00302 
00303 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines