Belle II Software development
AssignParameterVisitor Struct Reference

A helper class to unpack a boost::variant parameter value and set it in the parameter list. More...

#include <ParameterVariant.h>

Inheritance diagram for AssignParameterVisitor:

Public Member Functions

 AssignParameterVisitor (ModuleParamList *moduleParamList, const std::string &paramName)
 Constructor taking the module parameter list and the name of the parameter to be set from the boost::variant.
 
template<class T >
void operator() (const T &t) const
 Function call that receives the parameter value from the boost::variant with the correct type.
 

Static Public Member Functions

template<class ... T>
static void update (ModuleParamList *moduleParamList, const std::map< std::string, boost::variant< T... > > &valuesByName)
 Transfer all the parameters from the map boost:variant values to the module parameter list.
 

Private Attributes

ModuleParamListm_moduleParamList
 Parameter list which contains the parameter to be set.
 
std::string m_paramName
 Name of the parameter to be set.
 

Detailed Description

A helper class to unpack a boost::variant parameter value and set it in the parameter list.

Definition at line 35 of file ParameterVariant.h.

Constructor & Destructor Documentation

◆ AssignParameterVisitor()

AssignParameterVisitor ( ModuleParamList moduleParamList,
const std::string &  paramName 
)

Constructor taking the module parameter list and the name of the parameter to be set from the boost::variant.

Definition at line 18 of file ParameterVariant.cc.

20 : m_moduleParamList(moduleParamList)
21 , m_paramName(paramName)
22{
23}
ModuleParamList * m_moduleParamList
Parameter list which contains the parameter to be set.
std::string m_paramName
Name of the parameter to be set.

Member Function Documentation

◆ operator()()

template void operator() ( const T &  t) const

Function call that receives the parameter value from the boost::variant with the correct type.

Assign the value to a keyword in the dictionary.

Definition at line 27 of file ParameterVariant.cc.

28{
29 B2DEBUG(28, "Received parameter of type " << ModuleParam<T>::TypeInfo());
30 m_moduleParamList->getParameter<T>(m_paramName).setDefaultValue(t);
31}
A single parameter of the module.
Definition: ModuleParam.h:34
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.

◆ update()

static void update ( ModuleParamList moduleParamList,
const std::map< std::string, boost::variant< T... > > &  valuesByName 
)
inlinestatic

Transfer all the parameters from the map boost:variant values to the module parameter list.

Definition at line 39 of file ParameterVariant.h.

41 {
42 for (auto& nameAndValue : valuesByName) {
43 const std::string& name = nameAndValue.first;
44 const boost::variant<T...>& value = nameAndValue.second;
45 AssignParameterVisitor visitor(moduleParamList, name);
46 boost::apply_visitor(visitor, value);
47 }
48 }
AssignParameterVisitor(ModuleParamList *moduleParamList, const std::string &paramName)
Constructor taking the module parameter list and the name of the parameter to be set from the boost::...

Member Data Documentation

◆ m_moduleParamList

ModuleParamList* m_moduleParamList
private

Parameter list which contains the parameter to be set.

Definition at line 59 of file ParameterVariant.h.

◆ m_paramName

std::string m_paramName
private

Name of the parameter to be set.

Definition at line 62 of file ParameterVariant.h.


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