OpenMS
DefaultParamHandler Class Reference

A base class for all classes handling default parameters. More...

#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>

Inherited by SignalToNoiseEstimator< MSSpectrum >, AScore, AbsoluteQuantitation, AccurateMassSearchEngine, BaseGroupFinder, BaseModel, BaseSuperimposer, BasicProteinInferenceAlgorithm, BayesianProteinInferenceAlgorithm, BinnedSpectrumCompareFunctor, ConsensusIDAlgorithm, ConsensusMapMergerAlgorithm, DBSuitability, DIAScoring, DiaPrescore, ElutionModelFitter, ElutionPeakDetection, EmgGradientDescent, FIAMSDataProcessor, FLASHDeconvAlgorithm, FLASHDeconvWizardBase, FalseDiscoveryRate, FeatureDeconvolution, FeatureDistance, FeatureFinderAlgorithm, FeatureFinderAlgorithmMetaboIdent, FeatureFinderAlgorithmPicked, FeatureFinderIdentificationAlgorithm, FeatureFinderMultiplexAlgorithm, FeatureFindingMetabo, FeatureGroupingAlgorithm, Fitter1D, GNPSMGFFile, GaussFilter, IDDecoyProbability, IDMapper, IDMergerAlgorithm, IDRipper, IDScoreSwitcherAlgorithm, IsobaricChannelExtractor, IsobaricQuantifier, IsobaricQuantitationMethod, IsotopeLabelingMDVs, KDTreeFeatureMaps, LinearResampler, LowessSmoothing, MRMDecoy, MRMFeatureFilter, MRMFeatureFinderScoring, MRMMapping, MRMTransitionGroupPicker, MSPFile, MSPGenericFile, MapAlignmentAlgorithmIdentification, MapAlignmentAlgorithmPoseClustering, MapAlignmentAlgorithmTreeGuided, MascotGenericFile, MascotRemoteQuery, MassDecompositionAlgorithm, MassFeatureTrace, MassTraceDetection, MasstraceCorrelator, PosteriorErrorProbabilityModel, MetaboliteFeatureDeconvolution, MetaboliteSpectralMatching, MorphologicalFilter, MultiplexDeltaMassesGenerator, NLargest, Normalizer, NucleicAcidSpectrumGenerator, OpenPepXLAlgorithm, OpenPepXLLFAlgorithm, PeakIntegrator, PeakPickerChromatogram, PeakPickerHiRes, PeakPickerIterative, PeakSpectrumCompareFunctor, PeptideAndProteinQuant, PeptideIndexing, PlotCanvas, RankScaler, SONARScoring, SavitzkyGolayFilter, SignalToNoiseEstimator< Container >, SimpleSVM, SimpleSearchEngineAlgorithm, SimpleTSGXLMS, SiriusExportAlgorithm, SpectraIDViewTab, SpectraMerger, SpectraMerger::SpectraDistance_, SpectrumAlignment, SpectrumAnnotator, SqrtScaler, SwathMapMassCorrection, SwathWizardBase, TOPPASBase, TOPPViewBase, TargetedSpectraExtractor, TheoreticalSpectrumGenerator, TheoreticalSpectrumGeneratorXLMS, ThresholdMower, TraceFitter, TransitionTSVFile, WindowMower, and XFDRAlgorithm.

Collaboration diagram for DefaultParamHandler:
[legend]

Public Member Functions

 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 

Static Public Member Functions

static void writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="")
 Writes all parameters to meta values. More...
 

Protected Member Functions

virtual void updateMembers_ ()
 This method is used to update extra member variables at the end of the setParameters() method. More...
 
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 

Protected Attributes

Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 

Private Member Functions

 DefaultParamHandler ()
 Hidden default C'tor (class name parameter is required!) More...
 

Detailed Description

A base class for all classes handling default parameters.

This class facilitates the handling of parameters:

  • it manages default parameter (defaults_)
  • it checks for valid parameters:
    • unknown/misspelled parameter names
    • correct parameter type
    • range restrictions of numeric parameters
    • valid values for string parameters (enum)
  • subsections that are passed to other classes can be excluded from the check (subsections_)
  • it keeps member variables in synchronicity with the parameters stored in param_
  • it helps to automatically create a doxygen documentation page for the parameters

Extra member variables are needed if getting the value from param_ would be too slow e.g. when they are used in methods that are called very often.

No matter if you have extra variables or not, do the following:

  • Set defaults_ and subsections_ in the derived classes' default constructor.
  • Make sure to set the 'advanced' flag of the parameters right in order to hide certain parameters from inexperienced users.
  • Set the range restrictions for numeric defaults and valid strings for string defaults (if possible)
  • Call defaultsToParam_() at the end of derived classes' default constructor. It copies the defaults to param_ (and calls updateMembers_()).

If you have extra member variables you need to synchronize with param_, do the following:

  • Implement the updateMembers_() method. It is used after each change of param_ in order to update the extra member variables. If the base class is a DefaultParamHandler as well make sure to call the updateMembers_() method of the base class in the updateMembers_() method.
  • Call updateMembers_() at the end of the derived classes' copy constructor and assignment operator.
  • If you need mutable access to the extra member variables, provide a set-method and make sure to set the corresponding value in param_ as well!

Base classes:
If you create a class A that is derived from DefaultParamHandler and derive another class B for A, you should set use the setName(String) method to set the name used for error messages to B.

Parameter documentation:
Each default parameter has to be documented in a comprehensive way. This is done using the Param::setValue methods and the Param::setDescription method.

Flags:
Flags (boolean parameters) are not supported directly. It's best to implement them as a string parameter with valid strings 'true' and 'false'.

Constructor & Destructor Documentation

◆ DefaultParamHandler() [1/3]

DefaultParamHandler ( const String name)

Constructor with name that is displayed in error messages.

◆ DefaultParamHandler() [2/3]

Copy constructor.

◆ ~DefaultParamHandler()

virtual ~DefaultParamHandler ( )
virtual

Destructor.

◆ DefaultParamHandler() [3/3]

DefaultParamHandler ( )
private

Hidden default C'tor (class name parameter is required!)

Member Function Documentation

◆ defaultsToParam_()

◆ getDefaults()

◆ getName()

const String& getName ( ) const

Non-mutable access to the name.

Referenced by TOPPViewBase::zoomOtherWindows().

◆ getParameters()

◆ getSubsections()

const std::vector<String>& getSubsections ( ) const

Non-mutable access to the registered subsections.

◆ operator=()

DefaultParamHandler& operator= ( const DefaultParamHandler rhs)

◆ operator==()

virtual bool operator== ( const DefaultParamHandler rhs) const
virtual

Equality operator.

◆ setName()

◆ setParameters()

void setParameters ( const Param param)

◆ updateMembers_()

virtual void updateMembers_ ( )
protectedvirtual

This method is used to update extra member variables at the end of the setParameters() method.

Also call it at the end of the derived classes' copy constructor and assignment operator.

The default implementation is empty.

Reimplemented in SpectraMerger::SpectraDistance_, SavitzkyGolayFilter, LowessSmoothing, GaussFilter, Normalizer, LinearResamplerAlign, LinearResampler, SignalToNoiseEstimatorMedian< Container >, SignalToNoiseEstimatorMedian< OpenMS::MSChromatogram >, SignalToNoiseEstimatorMedian< ContainerT >, SignalToNoiseEstimatorMeanIterative< Container >, NLargest, PeakPickerIterative, PeakPickerHiRes, EmgGradientDescent, MSPGenericFile, MascotRemoteQuery, MascotGenericFile, TraceFitter, MaxLikeliFitter1D, MassTraceDetection, LevMarqFitter1D, IsotopeModel, IsotopeFitter1D, InterpolationModel, GaussTraceFitter, GaussModel, GaussFitter1D, Fitter1D, FeatureFindingMetabo, FeatureFinderIdentificationAlgorithm, FeatureFinderAlgorithmPicked, FeatureFinderAlgorithmMetaboIdent, ExtendedIsotopeModel, ExtendedIsotopeFitter1D, EmgModel, EmgFitter1D, ElutionPeakDetection, EGHTraceFitter, BiGaussModel, BiGaussFitter1D, BaseModel, BinnedSumAgreeingIntensities, BinnedSpectralContrastAngle, BinnedSharedPeakCount, TheoreticalSpectrumGeneratorXLMS, TheoreticalSpectrumGenerator, SpectrumAnnotator, SimpleTSGXLMS, NucleicAcidSpectrumGenerator, MassDecompositionAlgorithm, XFDRAlgorithm, OpenPepXLLFAlgorithm, OpenPepXLAlgorithm, MassFeatureTrace, FLASHDeconvAlgorithm, MRMMapping, TMTTenPlexQuantitationMethod, TMTSixteenPlexQuantitationMethod, TMTSixPlexQuantitationMethod, TMTElevenPlexQuantitationMethod, TMTEighteenPlexQuantitationMethod, PeptideAndProteinQuant, KDTreeFeatureMaps, ItraqFourPlexQuantitationMethod, ItraqEightPlexQuantitationMethod, IsotopeLabelingMDVs, IsobaricQuantifier, IsobaricChannelExtractor, AbsoluteQuantitation, TransitionTSVFile, TargetedSpectraExtractor, SwathMapMassCorrection, SONARScoring, PeakPickerChromatogram, PeakIntegrator, MRMTransitionGroupPicker, MRMFeatureFinderScoring, MRMFeatureFilter, MRMDecoy, DIAScoring, DiaPrescore, StablePairFinder, MapAlignmentAlgorithmTreeGuided, MapAlignmentAlgorithmPoseClustering, FeatureDistance, SimpleSearchEngineAlgorithm, PeptideIndexing, MetaboliteSpectralMatching, IDScoreSwitcherAlgorithm, IDMapper, FIAMSDataProcessor, ConsensusIDAlgorithmPEPMatrix, ConsensusIDAlgorithmPEPIons, ConsensusIDAlgorithm, BayesianProteinInferenceAlgorithm, AScore, AccurateMassSearchEngine, MetaboliteFeatureDeconvolution, and FeatureDeconvolution.

◆ writeParametersToMetaValues()

static void writeParametersToMetaValues ( const Param write_this,
MetaInfoInterface write_here,
const String key_prefix = "" 
)
static

Writes all parameters to meta values.

Parameters are written with 'name' as key and 'value' as value

Parameters
write_thisParams to be written
write_herea MetaInfoInterface object into which the meta values will be written
key_prefixWill be added in front of the parameter name for the meta value key. If the prefix isn't empty and doesn't end with a colon one will be added.

Member Data Documentation

◆ check_defaults_

bool check_defaults_
protected

If this member is set to false no checking if parameters in done;.

The only reason to set this member to false is that the derived class has no parameters! However, if a grand-child has defaults and you are using a base class cast, checking will not be done when casting back to grand-child. To just omit the warning, use 'warn_empty_defaults_'

◆ defaults_

Param defaults_
protected

Container for default parameters. This member should be filled in the constructor of derived classes!

Note
call the defaultsToParam_() method at the end of the constructor in order to copy the defaults to param_.

Referenced by BaseModel::BaseModel(), FeatureFinderAlgorithm::getDefaultParameters(), TOPPViewBase::initializeDefaultParameters_(), SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), SignalToNoiseEstimatorMedian< Container >::SignalToNoiseEstimatorMedian(), and TOPPASBase::TOPPASBase().

◆ error_name_

String error_name_
protected

Name that is displayed in error messages during the parameter checking.

◆ param_

◆ subsections_

std::vector<String> subsections_
protected

Container for registered subsections. This member should be filled in the constructor of derived classes!

Note
Do not add a ':' character at the end of subsections.

Referenced by TOPPViewBase::initializeDefaultParameters_(), and TOPPASBase::TOPPASBase().

◆ warn_empty_defaults_

bool warn_empty_defaults_
protected

If this member is set to false no warning is emitted when defaults are empty;.

The only reason to set this member to false is that the derived class has no parameters!

See also
check_defaults_