 |
Belle II Software
release-05-02-19
|
13 #include <framework/core/ModuleParamList.h>
14 #include <framework/core/ModuleParam.h>
15 #include <framework/logging/Logger.h>
32 const std::string& description,
33 const T& defaultValue)
35 ModuleParamPtr newParam(
new ModuleParam<T>(paramVariable, description,
false));
38 std::map<std::string, ModuleParamPtr>::iterator mapIter;
42 m_paramMap.insert(std::make_pair(name, newParam));
46 B2ERROR(
"A parameter with the name '" + name +
47 "' already exists! The name of a module parameter must be unique within a module.");
54 const std::string& description)
56 ModuleParamPtr newParam(
new ModuleParam<T>(paramVariable, description,
true));
59 std::map<std::string, ModuleParamPtr>::iterator mapIter;
63 m_paramMap.insert(std::make_pair(name, newParam));
65 B2ERROR(
"A parameter with the name '" + name +
66 "' already exists! The name of a module parameter must be unique within a module.");
74 ModuleParam<T>& explModParam = getParameter<T>(name);
75 explModParam.setValue(value);
76 }
catch (std::runtime_error& exc) {
85 std::map<std::string, ModuleParamPtr>::const_iterator mapIter;
105 template <
typename PythonObject>
110 p->setValueFromPythonObject(pyObj);
113 template <
typename PythonObject>
115 PythonObject& pyOutput,
116 bool defaultValues)
const
120 p->setValueToPythonObject(pyOutput, defaultValues);
121 }
catch (std::runtime_error& exc) {
ModuleParamPtr getParameterPtr(const std::string &name) const
Returns a ModuleParamPtr to a parameter.
std::map< std::string, ModuleParamPtr > m_paramMap
Stores the module parameters together with a string name as key.
void setDefaultValue(const T &defaultValue)
Sets the default value of a parameter.
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.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
A single parameter of the module.
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.
static void throwNotFoundError(const std::string &name)
Throws an error for a requested parameter that does not exist.
std::shared_ptr< ModuleParamBase > ModuleParamPtr
Defines a pointer to a module parameter as a boost shared pointer. */.
void setParameter(const std::string &name, const T &value)
Sets the value of a parameter given by its name.
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.