#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
This class facilitates the handling of 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:
If you have extra member variables you need to syncronize with param_, do the following:
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.
In order to avoid having to document the parameters in the code and in the doxygen documentation, there is a mechanism for creating the doxygen documentation automatically. You simply have to add your class to the program OpenMS/doc/doxygen/parameters/DefaultParamHandlerDocumenter.C. This program generates a doxygen subpage for the parameters. The subpage can than be included into the class documentation using the following doxygen command:
@ref <class name>_Parameters
Public Member Functions | |
DefaultParamHandler (const String &name) | |
Constructor with name that is diplayed in error messages. | |
DefaultParamHandler (const DefaultParamHandler &rhs) | |
Copy constructor. | |
virtual | ~DefaultParamHandler () |
Destructor. | |
virtual DefaultParamHandler & | operator= (const DefaultParamHandler &rhs) |
Assignment operator. | |
virtual bool | operator== (const DefaultParamHandler &rhs) const |
Equality operator. | |
void | setParameters (const Param ¶m) |
Sets the parameters. | |
const Param & | getParameters () const |
Non-mutable access to the parameters. | |
const Param & | getDefaults () const |
Non-mutable access to the default parameters. | |
const String & | getName () const |
Non-mutable access to the name. | |
void | setName (const String &name) |
Mutable access to the name. | |
const std::vector< String > & | getSubsections () const |
Non-mutable access to the registered subsections. | |
Protected Member Functions | |
virtual void | updateMembers_ () |
This method is used to update extra member variables at the end of the setParam() method. | |
void | defaultsToParam_ () |
Updates the parameters after the defaults have been set in the constructor. | |
Protected Attributes | |
Param | param_ |
Container for current parameters. | |
Param | defaults_ |
Container for default paramters. This member should be filled in the constructor of derived classes! | |
std::vector< String > | subsections_ |
Container for registered subsections. This member should be filled in the constructor of derived classes! | |
String | error_name_ |
Name that is displayed in error messages during the parameter checking. | |
bool | check_defaults_ |
If this member is set to false no checking if parameters in done;. | |
Private Member Functions | |
DefaultParamHandler () | |
Hidden as a name is required! |
DefaultParamHandler | ( | const String & | name | ) |
Constructor with name that is diplayed in error messages.
DefaultParamHandler | ( | const DefaultParamHandler & | rhs | ) |
Copy constructor.
virtual ~DefaultParamHandler | ( | ) | [virtual] |
Destructor.
DefaultParamHandler | ( | ) | [private] |
Hidden as a name is required!
virtual DefaultParamHandler& operator= | ( | const DefaultParamHandler & | rhs | ) | [virtual] |
Assignment operator.
virtual bool operator== | ( | const DefaultParamHandler & | rhs | ) | const [virtual] |
Equality operator.
void setParameters | ( | const Param & | param | ) |
Sets the parameters.
It also applies the default parameters to param
and checks for unknown parameters.
const Param& getParameters | ( | ) | const |
Non-mutable access to the parameters.
const Param& getDefaults | ( | ) | const |
Non-mutable access to the default parameters.
const String& getName | ( | ) | const |
Non-mutable access to the name.
void setName | ( | const String & | name | ) |
Mutable access to the name.
const std::vector<String>& getSubsections | ( | ) | const |
Non-mutable access to the registered subsections.
virtual void updateMembers_ | ( | ) | [protected, virtual] |
This method is used to update extra member variables at the end of the setParam() method.
Also call it at the end of the derived classes' copy constructor and assignment operator.
The default implementation is empty.
Reimplemented in BaseAlignment, BasePairwiseMapMatcher, DelaunayPairFinder, PoseClusteringAffineSuperimposer, PoseClusteringPairwiseMapMatcher, PoseClusteringShiftSuperimposer, SimplePairFinder, MorphFilter, InternalCalibration, SignalToNoiseEstimatorMeanIterative, SignalToNoiseEstimatorMedian, GaussFilter, SavitzkyGolayFilter, LinearResampler, BaseModel, BiGaussFitter1D, BiGaussModel, EmgFitter1D, EmgModel, ExtendedIsotopeFitter1D, ExtendedIsotopeModel, FeatureFinderAlgorithmPicked, Fitter1D, GaussFitter1D, GaussModel, InterpolationModel, IsotopeFitter1D, IsotopeModel, LevMarqFitter1D, LmaGaussFitter1D, LmaGaussModel, LmaIsotopeFitter1D, LmaIsotopeModel, MaxLikeliFitter1D, ModelFitter, ProductModel, SimpleExtender, OptimizePeakDeconvolution, PeakPicker, PeakPickerCWT, TwoDOptimization, BaseAlignment< AlignmentT::ConsensusElementType >, BaseModel< 1 >, and ProductModel< 2 >.
void defaultsToParam_ | ( | ) | [protected] |
Updates the parameters after the defaults have been set in the constructor.
Container for default paramters. This member should be filled in the constructor of derived classes!
std::vector<String> subsections_ [protected] |
Container for registered subsections. This member should be filled in the constructor of derived classes!
String error_name_ [protected] |
Name that is displayed in error messages during the parameter checking.
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!
Generated Tue Apr 1 15:36:43 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |