 |
Belle II Software
release-05-02-19
|
10 #include <framework/core/ModuleParamList.templateDetails.h>
12 #include <framework/core/ModuleParamInfoPython.h>
13 #include <framework/core/FrameworkExceptions.h>
15 #include <boost/python/object.hpp>
16 #include <boost/python/list.hpp>
25 "Could not find the parameter with the "
26 "name '%1%'! The value of the parameter "
31 "The type of the module parameter '%1%' "
32 "(%2%) is different from the type of the "
33 "value it should be set to (%3%)!");
37 throw (ModuleParameterNotFoundError() << name);
41 const std::string& expectedTypeInfo,
42 const std::string& typeInfo)
44 throw (ModuleParameterTypeError() << name << expectedTypeInfo << typeInfo);
58 std::vector<std::string> missingParam;
60 if (mapEntry.second->isForcedInSteering() && !mapEntry.second->isSetInSteering())
61 missingParam.push_back(mapEntry.first);
68 std::shared_ptr<boost::python::list> returnList(
new boost::python::list);
69 std::map<std::string, ModuleParamPtr>::const_iterator mapIter;
75 newParamInfo.
m_name = mapIter->first;
77 newParamInfo.
m_typeName = currParam->getTypeInfo();
83 returnList->append(boost::python::object(newParamInfo));
90 for (
const auto& param : params.m_paramMap) {
92 myParam->setValueFromParam(*param.second.get());
99 std::vector<std::string> names;
102 names.push_back(nameAndParam.first);
129 std::map<std::string, ModuleParamPtr>::const_iterator mapIter;
133 return mapIter->second;
134 }
else throw (ModuleParameterNotFoundError() << name);
ModuleParamPtr getParameterPtr(const std::string &name) const
Returns a ModuleParamPtr to a parameter.
std::string m_description
The description of the parameter.
std::map< std::string, ModuleParamPtr > m_paramMap
Stores the module parameters together with a string name as key.
std::string m_name
The name of the 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.
std::string m_typeName
The name of the type of the parameter.
bool m_setInSteering
True if the parameter was set in the steering file.
Class to store basic information about a parameter.
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.
void setParameters(const ModuleParamList ¶ms)
Set values for parameters from other parameter list.
ModuleParamList()
Constructor.
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.
~ModuleParamList()
Destructor.
bool m_forceInSteering
If true the parameter has to be set by the user in the steering file.
std::string getParameterTypeInfo(const std::string &name) const
Returns the type info of a parameter given by its name.
static void throwNotFoundError(const std::string &name)
Throws an error for a requested parameter that does not exist.
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
The Module parameter list class.
std::string getParameterDescription(const std::string &name) const
Returns the description of a parameter given by its name.
std::shared_ptr< ModuleParamBase > ModuleParamPtr
Defines a pointer to a module parameter as a boost shared pointer. */.
boost::python::list m_values
The values of the parameter as a python list.
boost::python::list m_defaultValues
The default values of the parameter as a python list.
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
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.
std::vector< std::string > getParameterNames() const
Returns the names of all parameters in this parameter list.