Belle II Software  release-08-01-10
ModuleParamList Class Reference

The Module parameter list class. More...

#include <ModuleParamList.h>

Collaboration diagram for ModuleParamList:

Public Member Functions

 ModuleParamList ()
 Constructor.
 
 ~ModuleParamList ()
 Destructor.
 
template<typename T >
void addParameter (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module list. More...
 
template<typename T >
void addParameter (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module list. More...
 
template<typename T >
void setParameter (const std::string &name, const T &value)
 Sets the value of a parameter given by its name. More...
 
void setParameters (const ModuleParamList &params)
 Set values for parameters from other parameter list.
 
std::vector< std::string > getParameterNames () const
 Returns the names of all parameters in this parameter list. More...
 
std::string getParameterDescription (const std::string &name) const
 Returns the description of a parameter given by its name. More...
 
std::string getParameterTypeInfo (const std::string &name) const
 Returns the type info of a parameter given by its name. More...
 
template<typename T >
ModuleParam< T > & getParameter (const std::string &name) const
 Returns a reference to a parameter. More...
 
std::vector< std::string > getUnsetForcedParams () const
 Returns list of unset parameters (if they are required to have a value.
 
std::shared_ptr< boost::python::list > getParamInfoListPython () const
 Returns a python list of all parameters. More...
 
template<typename PythonObject >
void setParamPython (const std::string &name, const PythonObject &pyObj)
 Implements a method for setting boost::python objects. More...
 
template<typename PythonObject >
void getParamValuesPython (const std::string &name, PythonObject &pyOutput, bool defaultValues) const
 Returns a python object containing the value or default value of the given parameter. More...
 

Private Member Functions

ModuleParamPtr getParameterPtr (const std::string &name) const
 Returns a ModuleParamPtr to a parameter. More...
 

Static Private Member Functions

static void throwNotFoundError (const std::string &name)
 Throws an error for a requested parameter that does not exist. More...
 
static void throwTypeError (const std::string &name, const std::string &expectedTypeInfo, const std::string &typeInfo)
 Throws an error for a requested parameter that exists but was request with the wrong type. More...
 

Private Attributes

std::map< std::string, ModuleParamPtrm_paramMap
 Stores the module parameters together with a string name as key.
 

Detailed Description

The Module parameter list class.

Stores and manages all parameters of a module.

Definition at line 44 of file ModuleParamList.h.

Member Function Documentation

◆ getParameterDescription()

std::string getParameterDescription ( const std::string &  name) const

Returns the description of a parameter given by its name.

Throws an exception of type ModuleParameterNotFoundError if a parameter with the given name does not exist.

Parameters
nameThe unique name of the parameter.
Returns
The description of the parameter as string

Definition at line 105 of file ModuleParamList.cc.

106 {
107  return getParameterPtr(name)->getDescription();
108 }
ModuleParamPtr getParameterPtr(const std::string &name) const
Returns a ModuleParamPtr to a parameter.

◆ getParameterNames()

std::vector< std::string > getParameterNames ( ) const

Returns the names of all parameters in this parameter list.

Returns
The names of the parameters

Definition at line 95 of file ModuleParamList.cc.

◆ getParameterPtr()

ModuleParamPtr getParameterPtr ( const std::string &  name) const
private

Returns a ModuleParamPtr to a parameter.

Throws an exception of type ModuleParameterNotFoundError if a parameter with the given name does not exist.

Parameters
nameThe unique name of the parameter.
Returns
A ModuleParamPtr to a module parameter.

Definition at line 124 of file ModuleParamList.cc.

◆ getParameterTypeInfo()

std::string getParameterTypeInfo ( const std::string &  name) const

Returns the type info of a parameter given by its name.

Throws an exception of type ModuleParameterNotFoundError if a parameter with the given name does not exist.

Parameters
nameThe unique name of the parameter.
Returns
The type information as descriptive string

Definition at line 110 of file ModuleParamList.cc.

◆ getParamInfoListPython()

std::shared_ptr< boost::python::list > getParamInfoListPython ( ) const

Returns a python list of all parameters.

Each item in the list consists of the name of the parameter, a string describing its type, a python list of all values, a python list of all default values, the information of the parameter was set in the steering file and the description of the parameter.

Returns
A python list containing the parameters of this parameter list.

Definition at line 64 of file ModuleParamList.cc.

◆ throwNotFoundError()

void throwNotFoundError ( const std::string &  name)
staticprivate

Throws an error for a requested parameter that does not exist.

Parameters
nameThe name of the parameter.

Definition at line 33 of file ModuleParamList.cc.

◆ throwTypeError()

void throwTypeError ( const std::string &  name,
const std::string &  expectedTypeInfo,
const std::string &  typeInfo 
)
staticprivate

Throws an error for a requested parameter that exists but was request with the wrong type.

Parameters
nameThe name of the parameter.
expectedTypeInfoType information which the parameter actually has.
typeInfoType information with which the parameter was looked up.

Definition at line 38 of file ModuleParamList.cc.


The documentation for this class was generated from the following files: