Parameters.h

00001 #ifndef gridripper_Parameters_h
00002 #define gridripper_Parameters_h
00003 
00004 #include <map>
00005 #include <gridripper/config.h>
00006 #include <gridripper/tvector.h>
00007 #include <gridripper/lang/IllegalArgumentException.h>
00008 #include <gridripper/math/expr/FnCollection.h>
00009 #include <gridripper/util/GrrProperties.h>
00010 #include <gridripper/util/ParameterPreprocessor.h>
00011 
00012 namespace gridripper {
00013 
00014 using namespace gridripper::util;
00015 using namespace gridripper::math::expr;
00016 using namespace std;
00017 
00024 class Parameters {
00025 
00026 private:
00027     GrrProperties properties;
00028     ParameterPreprocessor* preprocessor;
00029 
00030 public:
00034     Parameters() {
00035         preprocessor = new DummyParameterPreprocessor();
00036     }
00037 
00042     Parameters(const GrrProperties& props)
00043             throw(IllegalArgumentException&);
00044 
00048     Parameters(const Parameters& p);
00049 
00053     Parameters& operator =(const Parameters& p);
00054 
00055     ~Parameters();
00056 
00061     const ParameterPreprocessor* getPreprocessor() const {
00062         return preprocessor;
00063     }
00064 
00069     void setPreprocessor(ParameterPreprocessor* p) {
00070         if(preprocessor != NULL) {
00071             delete preprocessor;
00072         }
00073         preprocessor = p;
00074     }
00075 
00081     bool isSet(const string& name) const {
00082         map<string, string>::const_iterator it = getIterator(name);
00083         return it != properties.end();
00084     }
00085 
00091     GReal_t getReal(const string& name) const throw(IllegalArgumentException&);
00092 
00098     void setReal(const string& name, GReal_t v);
00099 
00105     int getInt(const string& name) const throw(IllegalArgumentException&);
00106 
00112     void setInt(const string& name, int v);
00113 
00119     tvector<int> getIntArray(const string& name) const
00120         throw(IllegalArgumentException&);
00121 
00127     void setIntArray(const string& name, const tvector<int>& arr);
00128 
00134     string getString(const string& name) const throw(IllegalArgumentException&);
00135 
00141     void setString(const string& name, const string& v);
00142 
00147     tvector<string> getParameterNames() const;
00148 
00153     const GrrProperties& getGrrProperties() const {
00154         return properties;
00155     }
00156 
00162     FnCollection* createFnCollection(const string& xname) const
00163         throw(IllegalArgumentException&);
00164 
00165 private:
00166     string getConstDefs() const;
00167 
00168     string getDefs() const;
00169 
00170     string mapName(const string& name) const;
00171 
00172     map<string, string>::const_iterator getIterator(const string& name) const {
00173         return properties.find(mapName(name));
00174     }
00175 
00176     void copy(const Parameters& o);
00177 
00178     void destruct();
00179 };
00180 
00181 } // namespace gridripper
00182 
00183 #endif /* gridripper_Parameters_h */

Generated on Wed Jun 17 18:46:47 2009 for GridRipper by  doxygen 1.5.6