[med-svn] [aghermann] 75/85: improve confval::
andrei zavada
hmmr-guest at alioth.debian.org
Thu Sep 26 23:46:36 UTC 2013
This is an automated email from the git hooks/post-receive script.
hmmr-guest pushed a commit to branch master
in repository aghermann.
commit 2c88ee2183b4e22deb3fbd42c72bb6cf504bbbf2
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Mon Sep 23 02:10:55 2013 +0300
improve confval::
---
upstream/src/aghermann/expdesign/dirlevel.cc | 27 ++-------
upstream/src/aghermann/expdesign/dirlevel.hh | 7 +--
upstream/src/aghermann/expdesign/expdesign.cc | 74 +++++++++++--------------
upstream/src/aghermann/expdesign/expdesign.hh | 7 +--
upstream/src/aghermann/expdesign/loadsave.cc | 26 +++------
upstream/src/aghermann/patterns/patterns.cc | 27 ++++-----
upstream/src/aghermann/rk1968/rk1968.cc | 5 +-
upstream/src/aghermann/ui/mw/loadsave.cc | 12 +---
upstream/src/aghermann/ui/mw/mw.cc | 64 ++++++++++-----------
upstream/src/aghermann/ui/mw/mw.hh | 13 ++---
upstream/src/aghermann/ui/sf/channel.cc | 59 ++++++++++----------
upstream/src/aghermann/ui/sf/channel.hh | 5 +-
upstream/src/aghermann/ui/sf/d/artifacts.cc | 37 ++++++-------
upstream/src/aghermann/ui/sf/sf.cc | 40 +++++--------
upstream/src/aghermann/ui/sf/sf.hh | 5 +-
upstream/src/common/config-validate.hh | 55 +++++++++++++++---
16 files changed, 213 insertions(+), 250 deletions(-)
diff --git a/upstream/src/aghermann/expdesign/dirlevel.cc b/upstream/src/aghermann/expdesign/dirlevel.cc
index d4b624d..8eaae66 100644
--- a/upstream/src/aghermann/expdesign/dirlevel.cc
+++ b/upstream/src/aghermann/expdesign/dirlevel.cc
@@ -80,18 +80,11 @@ int
CStorablePPack::
load()
{
- libconfig::Config conf;
+ libconfig::Config C;
try {
- conf.readFile( path().c_str());
-
- using namespace confval;
- get( config_keys_d, conf);
- get( config_keys_z, conf);
- get( config_keys_g, conf);
- get( config_keys_b, conf);
- get( config_keys_s, conf);
-
+ C.readFile( path().c_str());
+ config.get( C);
saved = true;
return 0;
@@ -116,17 +109,9 @@ save()
}
try {
- libconfig::Config conf;
-
- using namespace confval;
- put( config_keys_d, conf);
- put( config_keys_g, conf);
- put( config_keys_b, conf);
- put( config_keys_s, conf);
- put( config_keys_z, conf);
-
- conf.writeFile( p.c_str());
-
+ libconfig::Config C;
+ config.put( C);
+ C.writeFile( p.c_str());
saved = true;
return 0;
diff --git a/upstream/src/aghermann/expdesign/dirlevel.hh b/upstream/src/aghermann/expdesign/dirlevel.hh
index 68a3866..e7b01cc 100644
--- a/upstream/src/aghermann/expdesign/dirlevel.hh
+++ b/upstream/src/aghermann/expdesign/dirlevel.hh
@@ -109,11 +109,8 @@ class CStorablePPack {
{ saved = false; }
protected:
- forward_list<confval::SValidator<double>> config_keys_g;
- forward_list<confval::SValidator<int>> config_keys_d;
- forward_list<confval::SValidator<size_t>> config_keys_z;
- forward_list<confval::SValidator<bool>> config_keys_b;
- forward_list<confval::SValidator<string>> config_keys_s;
+ agh::confval::CConfigKeys
+ config;
};
diff --git a/upstream/src/aghermann/expdesign/expdesign.cc b/upstream/src/aghermann/expdesign/expdesign.cc
index b62033a..4a3779d 100644
--- a/upstream/src/aghermann/expdesign/expdesign.cc
+++ b/upstream/src/aghermann/expdesign/expdesign.cc
@@ -51,48 +51,40 @@ CExpDesign (const string& session_dir_,
af_dampen_factor (.95),
tunables0 (tstep, tlo, thi), // only references here, don't worry
strict_subject_id_checks (false),
- _id_pool (0),
- config_keys_g ({
- SValidator<double>("ctl_param.step_size", &ctl_params0.siman_params.step_size),
- SValidator<double>("ctl_param.boltzmann_k", &ctl_params0.siman_params.k, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
- SValidator<double>("ctl_param.t_initial", &ctl_params0.siman_params.t_initial, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
- SValidator<double>("ctl_param.damping_mu", &ctl_params0.siman_params.mu_t, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
- SValidator<double>("ctl_param.t_min", &ctl_params0.siman_params.t_min, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9)),
- SValidator<double>("profile.req_scored_pc", &profile_common_params0.req_percent_scored, SValidator<double>::SVFRangeIn( 80., 100.)),
- SValidator<double>("fft_param.pagesize", &fft_params.pagesize, SValidator<double>::SVFRangeIn( 4., 120.)),
- SValidator<double>("fft_param.binsize", &fft_params.binsize, SValidator<double>::SVFRangeIn( .125, 1.)),
- SValidator<double>("artifacts.dampen_factor", &af_dampen_factor, SValidator<double>::SVFRangeIn( 0., 1.)),
- SValidator<double>("mc_param.mc_gain", &mc_params.mc_gain, SValidator<double>::SVFRangeIn( 0., 100.)),
- SValidator<double>("mc_param.f0fc", &mc_params.f0fc, SValidator<double>::SVFRangeEx( 0., 80.)),
- SValidator<double>("mc_param.bandwidth", &mc_params.bandwidth, SValidator<double>::SVFRangeIn( 0.125, 2.)),
- SValidator<double>("mc_param.iir_backpolate", &mc_params.iir_backpolate, SValidator<double>::SVFRangeIn( 0., 1.)),
- SValidator<double>("swu_param.min_upswing_duration", &swu_params.min_upswing_duration, SValidator<double>::SVFRangeIn( 0.01, 1.)),
- }),
- config_keys_d ({
- SValidator<int>("fft_param.welch_window_type", (int*)&fft_params.welch_window_type, SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
- SValidator<int>("fft_param.plan_type", (int*)&fft_params.plan_type, SValidator<int>::SVFRangeIn( 0, (int)metrics::psd::TFFTWPlanType_total - 1)),
- SValidator<int>("artifacts.dampen_window_type", (int*)&af_dampen_window_type, SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1)),
- SValidator<int>("ctl_param.iters_fixed_t", &ctl_params0.siman_params.iters_fixed_T, SValidator<int>::SVFRangeIn( 1, 1000000)),
- SValidator<int>("ctl_param.n_tries", &ctl_params0.siman_params.n_tries, SValidator<int>::SVFRangeIn( 1, 10000)),
- }),
- config_keys_z ({
- SValidator<size_t>("smp.num_threads", &num_threads, SValidator<size_t>::SVFRangeIn( 0, 20)),
- SValidator<size_t>("mc_params.n_bins", &mc_params.n_bins, SValidator<size_t>::SVFRangeIn( 1, 100)),
- SValidator<size_t>("profile.swa_laden_pages_before_SWA_0", &profile_common_params0.swa_laden_pages_before_SWA_0, SValidator<size_t>::SVFRangeIn( 1, 100)),
- SValidator<size_t>("mc_param.smooth_side", &mc_params.smooth_side, SValidator<size_t>::SVFRangeIn( 0, 5)),
- }),
- config_keys_b ({
- SValidator<bool>("ctl_param.DBAmendment1", &ctl_params0.DBAmendment1),
- SValidator<bool>("ctl_param.DBAmendment2", &ctl_params0.DBAmendment2),
- SValidator<bool>("ctl_param.AZAmendment1", &ctl_params0.AZAmendment1),
- SValidator<bool>("ctl_param.AZAmendment2", &ctl_params0.AZAmendment2),
- SValidator<bool>("profile.score_unscored_as_wake", &profile_common_params0.score_unscored_as_wake),
- SValidator<bool>("StrictSubjectIdChecks", &strict_subject_id_checks),
- }),
- config_keys_s ({
- SValidator<string>("LastUsedVersion", &last_used_version),
- })
+ _id_pool (0)
{
+ config
+ ("ctl_param.step_size", &ctl_params0.siman_params.step_size)
+ ("ctl_param.boltzmann_k", &ctl_params0.siman_params.k, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9))
+ ("ctl_param.t_initial", &ctl_params0.siman_params.t_initial, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9))
+ ("ctl_param.damping_mu", &ctl_params0.siman_params.mu_t, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9))
+ ("ctl_param.t_min", &ctl_params0.siman_params.t_min, SValidator<double>::SVFRangeEx( DBL_MIN, 1e9))
+ ("profile.req_scored_pc", &profile_common_params0.req_percent_scored, SValidator<double>::SVFRangeIn( 80., 100.))
+ ("fft_param.pagesize", &fft_params.pagesize, SValidator<double>::SVFRangeIn( 4., 120.))
+ ("fft_param.binsize", &fft_params.binsize, SValidator<double>::SVFRangeIn( .125, 1.))
+ ("artifacts.dampen_factor", &af_dampen_factor, SValidator<double>::SVFRangeIn( 0., 1.))
+ ("mc_param.mc_gain", &mc_params.mc_gain, SValidator<double>::SVFRangeIn( 0., 100.))
+ ("mc_param.f0fc", &mc_params.f0fc, SValidator<double>::SVFRangeEx( 0., 80.))
+ ("mc_param.bandwidth", &mc_params.bandwidth, SValidator<double>::SVFRangeIn( 0.125, 2.))
+ ("mc_param.iir_backpolate", &mc_params.iir_backpolate, SValidator<double>::SVFRangeIn( 0., 1.))
+ ("swu_param.min_upswing_duration", &swu_params.min_upswing_duration, SValidator<double>::SVFRangeIn( 0.01, 1.))
+ ("fft_param.welch_window_type", (int*)&fft_params.welch_window_type, SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1))
+ ("fft_param.plan_type", (int*)&fft_params.plan_type, SValidator<int>::SVFRangeIn( 0, (int)metrics::psd::TFFTWPlanType_total - 1))
+ ("artifacts.dampen_window_type", (int*)&af_dampen_window_type, SValidator<int>::SVFRangeIn( 0, (int)sigproc::TWinType_total - 1))
+ ("ctl_param.iters_fixed_t", &ctl_params0.siman_params.iters_fixed_T, SValidator<int>::SVFRangeIn( 1, 1000000))
+ ("ctl_param.n_tries", &ctl_params0.siman_params.n_tries, SValidator<int>::SVFRangeIn( 1, 10000))
+ ("smp.num_threads", &num_threads, SValidator<size_t>::SVFRangeIn( 0, 20))
+ ("mc_params.n_bins", &mc_params.n_bins, SValidator<size_t>::SVFRangeIn( 1, 100))
+ ("profile.swa_laden_pages_before_SWA_0", &profile_common_params0.swa_laden_pages_before_SWA_0, SValidator<size_t>::SVFRangeIn( 1, 100))
+ ("mc_param.smooth_side", &mc_params.smooth_side, SValidator<size_t>::SVFRangeIn( 0, 5))
+ ("ctl_param.DBAmendment1", &ctl_params0.DBAmendment1)
+ ("ctl_param.DBAmendment2", &ctl_params0.DBAmendment2)
+ ("ctl_param.AZAmendment1", &ctl_params0.AZAmendment1)
+ ("ctl_param.AZAmendment2", &ctl_params0.AZAmendment2)
+ ("profile.score_unscored_as_wake", &profile_common_params0.score_unscored_as_wake)
+ ("StrictSubjectIdChecks", &strict_subject_id_checks)
+ ("LastUsedVersion", &last_used_version);
+
char *tmp = canonicalize_file_name(session_dir_.c_str());
if ( !tmp ) // does not exist
throw invalid_argument (string ("Failed to canonicalize dir: ") + session_dir_);
diff --git a/upstream/src/aghermann/expdesign/expdesign.hh b/upstream/src/aghermann/expdesign/expdesign.hh
index dda8066..2bf1fc8 100644
--- a/upstream/src/aghermann/expdesign/expdesign.hh
+++ b/upstream/src/aghermann/expdesign/expdesign.hh
@@ -258,11 +258,8 @@ class CExpDesign {
sid_t _id_pool;
// load/save
- forward_list<confval::SValidator<double>> config_keys_g;
- forward_list<confval::SValidator<int>> config_keys_d;
- forward_list<confval::SValidator<size_t>> config_keys_z;
- forward_list<confval::SValidator<bool>> config_keys_b;
- forward_list<confval::SValidator<string>> config_keys_s;
+ confval::CConfigKeys
+ config;
};
diff --git a/upstream/src/aghermann/expdesign/loadsave.cc b/upstream/src/aghermann/expdesign/loadsave.cc
index 7445ed1..c81fae4 100644
--- a/upstream/src/aghermann/expdesign/loadsave.cc
+++ b/upstream/src/aghermann/expdesign/loadsave.cc
@@ -28,12 +28,7 @@ load_settings()
try {
conf.readFile( EXPD_FILE);
- using namespace confval;
- get( config_keys_d, conf);
- get( config_keys_z, conf);
- get( config_keys_g, conf);
- get( config_keys_b, conf);
- get( config_keys_s, conf);
+ config.get( conf);
for ( size_t t = 0; t < ach::TTunable::_basic_tunables; ++t ) {
auto& A = conf.lookup(string("tunable.") + ach::tunable_name(t));
@@ -104,24 +99,19 @@ int
CExpDesign::
save_settings()
{
- libconfig::Config conf;
-
- confval::put( config_keys_d, conf);
- confval::put( config_keys_g, conf);
- confval::put( config_keys_b, conf);
- confval::put( config_keys_s, conf);
- confval::put( config_keys_z, conf);
+ libconfig::Config C;
+ config.put( C);
// only save _agh_basic_tunables_
for ( size_t t = 0; t < ach::TTunable::_basic_tunables; ++t )
- confval::put( conf, string("tunable.") + ach::tunable_name(t),
- forward_list<double> {tunables0[t], tlo[t], thi[t], tstep[t]});
+ confval::put( C, string("tunable.") + ach::tunable_name(t),
+ list<double> {tunables0[t], tlo[t], thi[t], tstep[t]});
for ( unsigned i = metrics::TBand::delta; i < metrics::TBand::TBand_total; ++i )
- confval::put( conf, string("Band.") + FreqBandNames[i],
- forward_list<double> {freq_bands[i][0], freq_bands[i][1]});
+ confval::put( C, string("Band.") + FreqBandNames[i],
+ list<double> {freq_bands[i][0], freq_bands[i][1]});
- conf.writeFile( EXPD_FILE);
+ C.writeFile( EXPD_FILE);
return 0;
}
diff --git a/upstream/src/aghermann/patterns/patterns.cc b/upstream/src/aghermann/patterns/patterns.cc
index 8d4faf0..fa6b8f1 100644
--- a/upstream/src/aghermann/patterns/patterns.cc
+++ b/upstream/src/aghermann/patterns/patterns.cc
@@ -213,21 +213,18 @@ SPattern (const string& name_, TExpDirLevel level_, CExpDesign& ED_, const SExpD
samplerate (0),
context ({0, 0})
{
- config_keys_g.assign({
- SValidator<double>("env_scope", &Pp.env_scope),
- SValidator<double>("bwf_ffrom", &Pp.bwf_ffrom),
- SValidator<double>("bwf_fupto", &Pp.bwf_fupto),
- SValidator<double>("dzcdf_step", &Pp.dzcdf_step),
- SValidator<double>("dzcdf_sigma", &Pp.dzcdf_sigma),
- SValidator<double>("criteria.c0", &get<0>(criteria)),
- SValidator<double>("criteria.c1", &get<1>(criteria)),
- SValidator<double>("criteria.c2", &get<2>(criteria)),
- SValidator<double>("criteria.c3", &get<3>(criteria)),
- });
- config_keys_d.assign({
- SValidator<int>("bwf_order", &Pp.bwf_order),
- SValidator<int>("dzcdf_smooth", &Pp.dzcdf_smooth),
- });
+ config
+ ("env_scope", &Pp.env_scope)
+ ("bwf_ffrom", &Pp.bwf_ffrom)
+ ("bwf_fupto", &Pp.bwf_fupto)
+ ("dzcdf_step", &Pp.dzcdf_step)
+ ("dzcdf_sigma", &Pp.dzcdf_sigma)
+ ("criteria.c0", &get<0>(criteria))
+ ("criteria.c1", &get<1>(criteria))
+ ("criteria.c2", &get<2>(criteria))
+ ("criteria.c3", &get<3>(criteria))
+ ("bwf_order", &Pp.bwf_order)
+ ("dzcdf_smooth", &Pp.dzcdf_smooth);
load();
}
diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index 99e54ef..43fb53f 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -33,10 +33,7 @@ CScoreAssistant (const string& name_,
TExpDirLevel level_, CExpDesign& ED_, const SExpDirLevelId& level_id_)
: CStorablePPack (common_subdir, name_, level_, ED_, level_id_)
{
- using agh::confval::SValidator;
- config_keys_g.assign({
- SValidator<double>("nrem3_delta_theta_ratio", &Pp.nrem3_delta_theta_ratio),
- });
+ config ("nrem3_delta_theta_ratio", &Pp.nrem3_delta_theta_ratio);
load();
}
diff --git a/upstream/src/aghermann/ui/mw/loadsave.cc b/upstream/src/aghermann/ui/mw/loadsave.cc
index 44e0982..5d54a76 100644
--- a/upstream/src/aghermann/ui/mw/loadsave.cc
+++ b/upstream/src/aghermann/ui/mw/loadsave.cc
@@ -85,10 +85,7 @@ load_settings()
try {
conf.readFile( CONF_FILE);
- agh::confval::get( config_keys_s, conf);
- agh::confval::get( config_keys_b, conf);
- agh::confval::get( config_keys_d, conf);
- agh::confval::get( config_keys_g, conf);
+ config.get( conf);
try {
auto& SC = conf.lookup("ScoreCodes");
@@ -161,17 +158,14 @@ save_settings()
_aghtt_placeholder = AghT();
_aghdd_placeholder = AghD();
- agh::confval::put( config_keys_s, conf);
- agh::confval::put( config_keys_b, conf);
- agh::confval::put( config_keys_d, conf);
- agh::confval::put( config_keys_g, conf);
+ config.put( conf);
agh::confval::put( conf, "ScoreCodes", ext_score_codes);
for ( auto &p : saving_colors() ) {
auto& C = CwB[p.second];
agh::confval::put( conf, string("Color.") + p.first,
- forward_list<double> {C.clr.red, C.clr.green, C.clr.blue, C.clr.alpha});
+ list<double> {C.clr.red, C.clr.green, C.clr.blue, C.clr.alpha});
}
conf.writeFile( CONF_FILE);
diff --git a/upstream/src/aghermann/ui/mw/mw.cc b/upstream/src/aghermann/ui/mw/mw.cc
index a7334e4..8f39009 100644
--- a/upstream/src/aghermann/ui/mw/mw.cc
+++ b/upstream/src/aghermann/ui/mw/mw.cc
@@ -159,42 +159,36 @@ SExpDesignUI (SSessionChooser *parent,
sort_by (TSubjectSortBy::name),
sort_ascending (true),
sort_segregate (false),
- browse_command ("thunar"),
- config_keys_s ({
- SValidator<string>("WindowGeometry.Main", &_geometry_placeholder),
- SValidator<string>("Common.CurrentSession", &_aghdd_placeholder),
- SValidator<string>("Common.CurrentChannel", &_aghtt_placeholder),
- SValidator<string>("Measurements.BrowseCommand", &browse_command),
- }),
- config_keys_b ({
- SValidator<bool>("Common.OnlyPlainAnnotations", &only_plain_global_annotations),
- SValidator<bool>("ScanTree.StrictSubjectIdCheck", &strict_subject_id_checks),
- SValidator<bool>("ScanTree.SuppressScanReport", &suppress_scan_report),
- }),
- config_keys_d ({
- SValidator<int>("Common.Sort.By", (int*)&sort_by, SValidator<int>::SVFRangeIn ( 0, 3)),
- SValidator<int>("Common.Sort.Ascending", (int*)&sort_ascending, SValidator<int>::SVFRangeIn ( 0, 1)),
- SValidator<int>("Common.Sort.Segregate", (int*)&sort_segregate, SValidator<int>::SVFRangeIn ( 0, 1)),
- SValidator<int>("Measurements.DisplayProfileType", (int*)&display_profile_type, SValidator<int>::SVFRangeIn ( 0, 3)),
- SValidator<int>("Measurements.SmoothSide", (int*)&smooth_profile, SValidator<int>::SVFRangeIn ( 1, 20)),
- SValidator<int>("Measurements.TimelineHeight", (int*)&tl_height, SValidator<int>::SVFRangeIn (10, 600)),
- SValidator<int>("Measurements.TimelinePPH", (int*)&tl_pph, SValidator<int>::SVFRangeIn (10, 600)),
- SValidator<int>("ScoringFacility.IntersignalSpace", (int*)&SScoringFacility::IntersignalSpace, SValidator<int>::SVFRangeIn (10, 800)),
- SValidator<int>("ScoringFacility.HypnogramHeight", (int*)&SScoringFacility::HypnogramHeight, SValidator<int>::SVFRangeIn (10, 300)),
- SValidator<int>("ModelRun.SWASmoothOver", (int*)&SModelrunFacility::swa_smoothover, SValidator<int>::SVFRangeIn ( 1, 5)),
- }),
- config_keys_g ({
- SValidator<double>("UltradianCycleDetectionAccuracy", &uc_accuracy_factor, SValidator<double>::SVFRangeIn (0.5, 20.)),
- SValidator<double>("Measurements.ProfileScalePSD", &profile_scale_psd, SValidator<double>::SVFRangeIn (0., 1e10)), // can be 0, will trigger autoscale
- SValidator<double>("Measurements.ProfileScaleSWU", &profile_scale_swu, SValidator<double>::SVFRangeIn (0., 1e10)),
- SValidator<double>("Measurements.ProfileScaleMC", &profile_scale_mc, SValidator<double>::SVFRangeIn (0., 1e10)),
- SValidator<double>("Profiles.PSD.FreqFrom", &active_profile_psd_freq_from, SValidator<double>::SVFRangeIn (0., 20.)),
- SValidator<double>("Profiles.PSD.FreqUpto", &active_profile_psd_freq_upto, SValidator<double>::SVFRangeIn (0., 20.)),
- SValidator<double>("Profiles.SWU.F0", &active_profile_swu_f0, SValidator<double>::SVFRangeIn (0., 20.)),
- SValidator<double>("Profiles.MC.F0", &active_profile_mc_f0, SValidator<double>::SVFRangeIn (0., 20.)),
- SValidator<double>("Common.ScrollFactor", &scroll_factor, SValidator<double>::SVFRangeIn (1.001, 1.5)),
- })
+ browse_command ("thunar")
{
+ config
+ ("WindowGeometry.Main", &_geometry_placeholder)
+ ("Common.CurrentSession", &_aghdd_placeholder)
+ ("Common.CurrentChannel", &_aghtt_placeholder)
+ ("Measurements.BrowseCommand", &browse_command)
+ ("Common.OnlyPlainAnnotations", &only_plain_global_annotations)
+ ("ScanTree.StrictSubjectIdCheck", &strict_subject_id_checks)
+ ("ScanTree.SuppressScanReport", &suppress_scan_report)
+ ("Common.Sort.By", (int*)&sort_by, SValidator<int>::SVFRangeIn ( 0, 3))
+ ("Common.Sort.Ascending", (int*)&sort_ascending, SValidator<int>::SVFRangeIn ( 0, 1))
+ ("Common.Sort.Segregate", (int*)&sort_segregate, SValidator<int>::SVFRangeIn ( 0, 1))
+ ("Measurements.DisplayProfileType", (int*)&display_profile_type, SValidator<int>::SVFRangeIn ( 0, 3))
+ ("Measurements.SmoothSide", (int*)&smooth_profile, SValidator<int>::SVFRangeIn ( 1, 20))
+ ("Measurements.TimelineHeight", (int*)&tl_height, SValidator<int>::SVFRangeIn (10, 600))
+ ("Measurements.TimelinePPH", (int*)&tl_pph, SValidator<int>::SVFRangeIn (10, 600))
+ ("ScoringFacility.IntersignalSpace", (int*)&SScoringFacility::IntersignalSpace, SValidator<int>::SVFRangeIn (10, 800))
+ ("ScoringFacility.HypnogramHeight", (int*)&SScoringFacility::HypnogramHeight, SValidator<int>::SVFRangeIn (10, 300))
+ ("ModelRun.SWASmoothOver", (int*)&SModelrunFacility::swa_smoothover, SValidator<int>::SVFRangeIn ( 1, 5))
+ ("UltradianCycleDetectionAccuracy", &uc_accuracy_factor, SValidator<double>::SVFRangeIn (0.5, 20.))
+ ("Measurements.ProfileScalePSD", &profile_scale_psd, SValidator<double>::SVFRangeIn (0., 1e10)) // can be 0, will trigger autoscal
+ ("Measurements.ProfileScaleSWU", &profile_scale_swu, SValidator<double>::SVFRangeIn (0., 1e10))
+ ("Measurements.ProfileScaleMC", &profile_scale_mc, SValidator<double>::SVFRangeIn (0., 1e10))
+ ("Profiles.PSD.FreqFrom", &active_profile_psd_freq_from, SValidator<double>::SVFRangeIn (0., 20.))
+ ("Profiles.PSD.FreqUpto", &active_profile_psd_freq_upto, SValidator<double>::SVFRangeIn (0., 20.))
+ ("Profiles.SWU.F0", &active_profile_swu_f0, SValidator<double>::SVFRangeIn (0., 20.))
+ ("Profiles.MC.F0", &active_profile_mc_f0, SValidator<double>::SVFRangeIn (0., 20.))
+ ("Common.ScrollFactor", &scroll_factor, SValidator<double>::SVFRangeIn (1.001, 1.5));
+
nodestroy_by_cb = true;
suppress_redraw = true;
diff --git a/upstream/src/aghermann/ui/mw/mw.hh b/upstream/src/aghermann/ui/mw/mw.hh
index a9eba59..b813781 100644
--- a/upstream/src/aghermann/ui/mw/mw.hh
+++ b/upstream/src/aghermann/ui/mw/mw.hh
@@ -340,13 +340,6 @@ class SExpDesignUI
SGeometry
geometry;
- forward_list<agh::confval::SValidator<string>> config_keys_s;
- forward_list<agh::confval::SValidator<bool>> config_keys_b;
- forward_list<agh::confval::SValidator<int>> config_keys_d;
- forward_list<agh::confval::SValidator<double>> config_keys_g;
- int load_settings();
- int save_settings();
-
void populate_mSessions();
void populate_mChannels();
void populate_mGlobalAnnotations();
@@ -359,6 +352,12 @@ class SExpDesignUI
FFTPageSizeValues;
static const array<double, 3>
FFTBinSizeValues;
+
+ private:
+ agh::confval::CConfigKeys
+ config;
+ int load_settings();
+ int save_settings();
};
diff --git a/upstream/src/aghermann/ui/sf/channel.cc b/upstream/src/aghermann/ui/sf/channel.cc
index 4643931..7fc8d2e 100644
--- a/upstream/src/aghermann/ui/sf/channel.cc
+++ b/upstream/src/aghermann/ui/sf/channel.cc
@@ -67,36 +67,6 @@ SChannel (agh::CRecording& r,
draw_phasic_Kcomplex (true),
draw_phasic_eyeblink (true),
apply_reconstituted (false),
- config_keys_b ({
- SValidator<bool>( string("h")+to_string(seq) + ".hidden", &hidden),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_zeroline", &draw_zeroline),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_original_signal", &draw_original_signal),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_filtered_signal", &draw_filtered_signal),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_emg", &draw_emg),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_psd", &draw_psd),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_swu", &draw_swu),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_psd_bands", &draw_psd_bands),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_spectrum", &draw_spectrum),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_mc", &draw_mc),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_phasic_spindle", &draw_phasic_spindle),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_phasic_Kcomplex", &draw_phasic_Kcomplex),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_phasic_eyeblink", &draw_phasic_eyeblink),
- SValidator<bool>( string("h")+to_string(seq) + ".autoscale_profile", &autoscale_profile),
- SValidator<bool>( string("h")+to_string(seq) + ".resample_signal", &resample_signal),
- SValidator<bool>( string("h")+to_string(seq) + ".resample_power", &resample_power),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_selection_course", &draw_selection_course),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_selection_envelope", &draw_selection_envelope),
- SValidator<bool>( string("h")+to_string(seq) + ".draw_selection_dzcdf", &draw_selection_dzcdf),
- }),
- config_keys_g ({
- SValidator<double>( string("h")+to_string(seq) + ".zeroy", &zeroy, SValidator<double>::SVFRangeIn (-100., 4000.)),
- SValidator<double>( string("h")+to_string(seq) + ".selection_start_time", &selection_start_time),
- SValidator<double>( string("h")+to_string(seq) + ".selection_end_time", &selection_end_time),
- SValidator<double>( string("h")+to_string(seq) + ".signal_display_scale", &signal_display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY)),
- SValidator<double>( string("h")+to_string(seq) + ".psd_display_scale", &psd.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY)),
- SValidator<double>( string("h")+to_string(seq) + ".swu_display_scale", &swu.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY)),
- SValidator<double>( string("h")+to_string(seq) + ".mc_display_scale", &mc.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY)),
- }),
marquee_start (0.),
marquee_end (0.),
selection_start_time (0.),
@@ -104,6 +74,35 @@ SChannel (agh::CRecording& r,
selection_start (0),
selection_end (0)
{
+ config
+ ( string("h")+to_string(seq) + ".hidden", &hidden)
+ ( string("h")+to_string(seq) + ".draw_zeroline", &draw_zeroline)
+ ( string("h")+to_string(seq) + ".draw_original_signal", &draw_original_signal)
+ ( string("h")+to_string(seq) + ".draw_filtered_signal", &draw_filtered_signal)
+ ( string("h")+to_string(seq) + ".draw_emg", &draw_emg)
+ ( string("h")+to_string(seq) + ".draw_psd", &draw_psd)
+ ( string("h")+to_string(seq) + ".draw_swu", &draw_swu)
+ ( string("h")+to_string(seq) + ".draw_psd_bands", &draw_psd_bands)
+ ( string("h")+to_string(seq) + ".draw_spectrum", &draw_spectrum)
+ ( string("h")+to_string(seq) + ".draw_mc", &draw_mc)
+ ( string("h")+to_string(seq) + ".draw_phasic_spindle", &draw_phasic_spindle)
+ ( string("h")+to_string(seq) + ".draw_phasic_Kcomplex", &draw_phasic_Kcomplex)
+ ( string("h")+to_string(seq) + ".draw_phasic_eyeblink", &draw_phasic_eyeblink)
+ ( string("h")+to_string(seq) + ".autoscale_profile", &autoscale_profile)
+ ( string("h")+to_string(seq) + ".resample_signal", &resample_signal)
+ ( string("h")+to_string(seq) + ".resample_power", &resample_power)
+ ( string("h")+to_string(seq) + ".draw_selection_course", &draw_selection_course)
+ ( string("h")+to_string(seq) + ".draw_selection_envelope", &draw_selection_envelope)
+ ( string("h")+to_string(seq) + ".draw_selection_dzcdf", &draw_selection_dzcdf)
+ ( string("h")+to_string(seq) + ".zeroy", &zeroy, SValidator<double>::SVFRangeIn (-100., 4000.))
+ ( string("h")+to_string(seq) + ".selection_start_time", &selection_start_time)
+ ( string("h")+to_string(seq) + ".selection_end_time", &selection_end_time)
+ ( string("h")+to_string(seq) + ".signal_display_scale", &signal_display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY))
+ ( string("h")+to_string(seq) + ".psd_display_scale", &psd.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY))
+ ( string("h")+to_string(seq) + ".swu_display_scale", &swu.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY))
+ ( string("h")+to_string(seq) + ".mc_display_scale", &mc.display_scale, SValidator<double>::SVFRangeIn (DBL_MIN, INFINITY));
+
+
get_signal_original();
get_signal_filtered();
diff --git a/upstream/src/aghermann/ui/sf/channel.hh b/upstream/src/aghermann/ui/sf/channel.hh
index 57a95b6..761cb64 100644
--- a/upstream/src/aghermann/ui/sf/channel.hh
+++ b/upstream/src/aghermann/ui/sf/channel.hh
@@ -214,9 +214,8 @@ struct SScoringFacility::SChannel {
bool discard_marked,
apply_reconstituted;
- forward_list<agh::confval::SValidator<bool>> config_keys_b;
- forward_list<agh::confval::SValidator<int>> config_keys_d;
- forward_list<agh::confval::SValidator<double>> config_keys_g;
+ agh::confval::CConfigKeys
+ config;
void update_channel_menu_items( double x);
void update_power_menu_items();
diff --git a/upstream/src/aghermann/ui/sf/d/artifacts.cc b/upstream/src/aghermann/ui/sf/d/artifacts.cc
index d08540b..e39e4d7 100644
--- a/upstream/src/aghermann/ui/sf/d/artifacts.cc
+++ b/upstream/src/aghermann/ui/sf/d/artifacts.cc
@@ -162,27 +162,22 @@ CArtifactDetector (const string& name_, agh::TExpDirLevel level_, agh::CExpDesig
: CStorablePPack (common_subdir, name_, level_, ED_, level_id_)
{
using agh::confval::SValidator;
- config_keys_g.assign({
- SValidator<double>("scope", &Pp.scope, SValidator<double>::SVFRangeIn (0.5, 60.)),
- SValidator<double>("upper_thr", &Pp.upper_thr, SValidator<double>::SVFRangeIn (0., 100.)),
- SValidator<double>("lower_thr", &Pp.lower_thr, SValidator<double>::SVFRangeIn (-100., 0.)),
- SValidator<double>("f0", &Pp.f0, SValidator<double>::SVFRangeIn (.1, 80.)),
- SValidator<double>("fc", &Pp.fc, SValidator<double>::SVFRangeIn (.1, 80.)),
- SValidator<double>("bandwidth", &Pp.bandwidth, SValidator<double>::SVFRangeIn (.1, 40.)),
- SValidator<double>("mc_gain", &Pp.mc_gain, SValidator<double>::SVFRangeIn (0., 100.)),
- SValidator<double>("iir_backpolate", &Pp.iir_backpolate, SValidator<double>::SVFRangeIn (0., 1.)),
- SValidator<double>("E", &Pp.E, SValidator<double>::SVFRangeIn (.1, 100.)),
- SValidator<double>("dmin", &Pp.dmin, SValidator<double>::SVFRangeIn (-100., 100.)),
- SValidator<double>("dmax", &Pp.dmax, SValidator<double>::SVFRangeIn (-100., 100.)),
- });
- config_keys_z.assign({
- SValidator<size_t>("sssu_hist_size", &Pp.sssu_hist_size, SValidator<size_t>::SVFRangeIn (10, 1000)),
- SValidator<size_t>("smooth_side", &Pp.smooth_side, SValidator<size_t>::SVFRangeIn (0, 10)),
- });
- config_keys_b.assign({
- SValidator<bool>("estimate_E", &Pp.estimate_E),
- SValidator<bool>("use_range", &Pp.use_range),
- });
+ config
+ ("scope", &Pp.scope, SValidator<double>::SVFRangeIn (0.5, 60.))
+ ("upper_thr", &Pp.upper_thr, SValidator<double>::SVFRangeIn (0., 100.))
+ ("lower_thr", &Pp.lower_thr, SValidator<double>::SVFRangeIn (-100., 0.))
+ ("f0", &Pp.f0, SValidator<double>::SVFRangeIn (.1, 80.))
+ ("fc", &Pp.fc, SValidator<double>::SVFRangeIn (.1, 80.))
+ ("bandwidth", &Pp.bandwidth, SValidator<double>::SVFRangeIn (.1, 40.))
+ ("mc_gain", &Pp.mc_gain, SValidator<double>::SVFRangeIn (0., 100.))
+ ("iir_backpolate", &Pp.iir_backpolate, SValidator<double>::SVFRangeIn (0., 1.))
+ ("E", &Pp.E, SValidator<double>::SVFRangeIn (.1, 100.))
+ ("dmin", &Pp.dmin, SValidator<double>::SVFRangeIn (-100., 100.))
+ ("dmax", &Pp.dmax, SValidator<double>::SVFRangeIn (-100., 100.))
+ ("sssu_hist_size", &Pp.sssu_hist_size, SValidator<size_t>::SVFRangeIn (10, 1000))
+ ("smooth_side", &Pp.smooth_side, SValidator<size_t>::SVFRangeIn (0, 10))
+ ("estimate_E", &Pp.estimate_E)
+ ("use_range", &Pp.use_range);
make_default_SArtifactDetectionPPack( Pp);
load();
diff --git a/upstream/src/aghermann/ui/sf/sf.cc b/upstream/src/aghermann/ui/sf/sf.cc
index 3e2c309..47cd356 100644
--- a/upstream/src/aghermann/ui/sf/sf.cc
+++ b/upstream/src/aghermann/ui/sf/sf.cc
@@ -79,19 +79,6 @@ SScoringFacility (agh::CSubject& J,
ica (nullptr),
interchannel_gap (IntersignalSpace),
n_hidden (0),
- config_keys_b ({
- SValidator<bool>("show_cur_pos_time_relative", &show_cur_pos_time_relative),
- SValidator<bool>("draw.crosshair", &draw_crosshair),
- SValidator<bool>("draw.alt_hypnogram", &alt_hypnogram),
- }),
- config_keys_d ({
- SValidator<int>("cur_vpage", (int*)&_cur_vpage, SValidator<int>::SVFRangeIn (0, INT_MAX)),
- SValidator<int>("pagesize_item", (int*)&pagesize_item, SValidator<int>::SVFRangeIn (0, DisplayPageSizeValues.size()-1)),
- }),
- config_keys_g ({
- SValidator<float>("montage.interchannel_gap", &interchannel_gap, SValidator<float>::SVFRangeIn (0., 400.)),
- SValidator<float>("montage.height", &da_ht, SValidator<float>::SVFRangeIn (10., 4000.)),
- }),
_patterns_d (nullptr),
_filters_d (nullptr),
_phasediff_d (nullptr),
@@ -102,6 +89,15 @@ SScoringFacility (agh::CSubject& J,
da_wd (800), // gets properly set in a configure_event cb
da_ht (NAN) // bad value, to be estimated unless previously saved
{
+ config
+ ("show_cur_pos_time_relative", &show_cur_pos_time_relative)
+ ("draw.crosshair", &draw_crosshair)
+ ("draw.alt_hypnogram", &alt_hypnogram)
+ ("cur_vpage", (int*)&_cur_vpage, SValidator<int>::SVFRangeIn (0, INT_MAX))
+ ("pagesize_item", (int*)&pagesize_item, SValidator<int>::SVFRangeIn (0, DisplayPageSizeValues.size()-1))
+ ("montage.interchannel_gap", &interchannel_gap, SValidator<float>::SVFRangeIn (0., 400.))
+ ("montage.height", &da_ht, SValidator<float>::SVFRangeIn (10., 4000.));
+
SBusyBlock bb (_p.wMainWindow);
// complete widget construction
@@ -736,13 +732,10 @@ load_montage()
} catch (libconfig::FileIOException ex) {
return;
}
- agh::confval::get( config_keys_b, conf);
- agh::confval::get( config_keys_d, conf);
+ config.get( conf);
for ( auto &h : channels ) {
- agh::confval::get( h.config_keys_b, conf);
- agh::confval::get( h.config_keys_d, conf);
- agh::confval::get( h.config_keys_g, conf);
+ h.config.get( conf);
// postprocess a little
h.selection_start = h.selection_start_time * h.samplerate();
@@ -766,14 +759,11 @@ SScoringFacility::
save_montage()
{
libconfig::Config conf;
- agh::confval::put( config_keys_b, conf);
- agh::confval::put( config_keys_d, conf);
+ config.put( conf);
+
+ for ( auto &h : channels )
+ h.config.put( conf);
- for ( auto &h : channels ) {
- agh::confval::put( h.config_keys_b, conf);
- agh::confval::put( h.config_keys_d, conf);
- agh::confval::put( h.config_keys_g, conf);
- }
try {
conf.writeFile (
(agh::fs::make_fname_base(
diff --git a/upstream/src/aghermann/ui/sf/sf.hh b/upstream/src/aghermann/ui/sf/sf.hh
index 054924a..2623262 100644
--- a/upstream/src/aghermann/ui/sf/sf.hh
+++ b/upstream/src/aghermann/ui/sf/sf.hh
@@ -243,9 +243,8 @@ class SScoringFacility
// montage
// load/save/reset
public:
- forward_list<agh::confval::SValidator<bool>> config_keys_b;
- forward_list<agh::confval::SValidator<int>> config_keys_d;
- forward_list<agh::confval::SValidator<float>> config_keys_g;
+ agh::confval::CConfigKeys
+ config;
void load_montage();
void save_montage(); // using libconfig
void reset_montage();
diff --git a/upstream/src/common/config-validate.hh b/upstream/src/common/config-validate.hh
index a44ba16..306c305 100644
--- a/upstream/src/common/config-validate.hh
+++ b/upstream/src/common/config-validate.hh
@@ -14,7 +14,7 @@
#include <limits.h>
-#include <forward_list>
+#include <list>
#include <array>
#include <functional>
#include <stdexcept>
@@ -72,13 +72,13 @@ inline void
put( libconfig::Config& C, const string& key, const size_t& value)
{
if ( value > INT_MAX )
- fprintf( stderr, "Value being saved is way too long for any practical purpose (unintialized?): %zu\n", value);
+ fprintf( stderr, "Value being saved is way too big for any practical purpose (unintialized?): %zu\n", value);
ensure_path( C.getRoot(), libconfig_type_id<int>(), key) = (int)value;
}
template <typename T>
void
-put( libconfig::Config& C, const string& key, const forward_list<T>& vl)
+put( libconfig::Config& C, const string& key, const list<T>& vl)
{
auto& S = ensure_path( C.getRoot(), libconfig::Setting::Type::TypeList, key);
for ( auto& V : vl )
@@ -97,11 +97,15 @@ put( libconfig::Config& C, const string& key, const array<T, N>& vl)
-
+struct IValidator {
+ virtual void get( const libconfig::Config&) const = 0;
+ virtual void put( libconfig::Config&) const = 0;
+ virtual ~IValidator() {} // -Wdelete-non-virtual-dtor
+};
template <typename T>
-struct SValidator {
+struct SValidator : IValidator {
string key;
T* rcp;
struct SVFTrue {
@@ -117,6 +121,7 @@ struct SValidator {
SVFRangeIn( const T& _lo, const T& _hi) : lo(_lo), hi(_hi) {};
bool operator() ( const T& v) const { return v >= lo && v <= hi; }
};
+ // using TValidator function<bool(const T&)>;
function<bool(const T&)> valf;
template <typename K>
@@ -167,7 +172,8 @@ struct SValidator {
template <>
inline void
-SValidator<size_t>::get( const libconfig::Config& C) const
+SValidator<size_t>::
+get( const libconfig::Config& C) const
{
int tmp; // libconfig doesn't deal in unsigned values
if ( not C.lookupValue( key, tmp) ) {
@@ -182,7 +188,7 @@ SValidator<size_t>::get( const libconfig::Config& C) const
template <typename T>
void
-get( forward_list<SValidator<T>>& vl,
+get( list<SValidator<T>>& vl,
libconfig::Config& conf,
bool nothrow = true)
{
@@ -199,7 +205,7 @@ get( forward_list<SValidator<T>>& vl,
template <typename T>
void
-put( forward_list<SValidator<T>>& vl,
+put( list<SValidator<T>>& vl,
libconfig::Config& conf)
{
for ( auto& V : vl )
@@ -208,6 +214,39 @@ put( forward_list<SValidator<T>>& vl,
+
+// collections of SValidator
+
+class CConfigKeys {
+ public:
+ list<IValidator*> S;
+ ~CConfigKeys ()
+ {
+ for ( auto& K : S )
+ delete K;
+ }
+
+ template <class K, class V>
+ CConfigKeys& operator()( const K& k, V* v)
+ { return S.push_back( new SValidator<V>(k, v)), *this; }
+
+ template <class K, class V, class F>
+ CConfigKeys& operator()( const K& k, V* v, const F& f)
+ { return S.push_back( new SValidator<V>(k, v, f)), *this; }
+
+ void get( libconfig::Config& C)
+ {
+ for ( auto& K : S )
+ K->get( C);
+ }
+ void put( libconfig::Config& C)
+ {
+ for ( auto& K : S )
+ K->put( C);
+ }
+};
+
+
} // namespace confval
} // namespace agh
--
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git
More information about the debian-med-commit
mailing list