00001
00002
00003
00004 #ifndef FITYK__SETTINGS__H__
00005 #define FITYK__SETTINGS__H__
00006 #include <map>
00007 #include <utility>
00008 #include "common.h"
00009
00010 class Ftk;
00011
00012
00013 struct Settings
00014 {
00015
00016 int verbosity;
00017 bool autoplot;
00018 bool exit_on_warning;
00019 double epsilon;
00020 const char* default_sigma;
00021 int pseudo_random_seed;
00022 std::string numeric_format;
00023 std::string logfile;
00024 bool log_full;
00025 double function_cutoff;
00026
00027
00028 double height_correction;
00029 double width_correction;
00030 bool guess_uses_weights;
00031
00032
00033 const char* fitting_method;
00034 int max_wssr_evaluations;
00035 double max_fitting_time;
00036 int refresh_period;
00037 bool fit_replot;
00038 double domain_percent;
00039
00040 double lm_lambda_start;
00041 double lm_lambda_up_factor;
00042 double lm_lambda_down_factor;
00043 double lm_stop_rel_change;
00044 double lm_max_lambda;
00045
00046 double nm_convergence;
00047 bool nm_move_all;
00048 const char* nm_distribution;
00049 double nm_move_factor;
00050 };
00051
00052
00053 class SettingsMgr
00054 {
00055 public:
00056 enum ValueType
00057 {
00058 kInt,
00059 kDouble,
00060 kBool,
00061 kString,
00062 kEnum,
00063 kNotFound
00064 };
00065
00066 SettingsMgr(Ftk const* F);
00067
00068
00069 static std::vector<std::string> get_key_list (const std::string& start);
00070
00071
00072 static const char** get_allowed_values(const std::string& k);
00073
00074
00075 static ValueType get_value_type(const std::string& k);
00076
00077
00078 static std::string get_type_desc(const std::string& k);
00079
00080
00081 const Settings& m() const { return m_; }
00082
00083 std::string get_as_string(const std::string& k) const;
00084
00085 int get_enum_index(const std::string& k) const;
00086
00087
00088 void set_as_string(const std::string& k, const std::string& v);
00089 void set_as_number(const std::string& k, double v);
00090 void set_all(const Settings& s) { m_ = s; epsilon = s.epsilon; }
00091
00092
00093 void do_srand();
00094 std::string format_double(double d) const
00095 { return format1<double, 32>(m_.numeric_format.c_str(), d); }
00096 #if USE_LONG_DOUBLE
00097 std::string format_double(long double d) const
00098 { return format1<long double, 64>(long_double_format_.c_str(), d); }
00099 #endif
00100
00101 private:
00102 const Ftk* F_;
00103 Settings m_;
00104 std::string long_double_format_;
00105
00106 void set_long_double_format(const std::string& double_fmt);
00107 DISALLOW_COPY_AND_ASSIGN(SettingsMgr);
00108 };
00109
00110 #endif
00111