Belle II Software development
ParameterVariant.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/utilities/ParameterVariant.h>
9
10#include <framework/core/ModuleParamList.templateDetails.h>
11#include <framework/core/ModuleParam.templateDetails.h>
12
13#include <framework/logging/Logger.h>
14
15using namespace Belle2;
16using namespace TrackFindingCDC;
17
19 const std::string& paramName)
20 : m_moduleParamList(moduleParamList)
21 , m_paramName(paramName)
22{
23}
24
26template <class T>
28{
29 B2DEBUG(28, "Received parameter of type " << ModuleParam<T>::TypeInfo());
30 m_moduleParamList->getParameter<T>(m_paramName).setDefaultValue(t);
31}
32
33// Make explicit template function instances of
34// namespace Belle2 {
35// namespace TrackingFindingCDC {
36// /// template<typename T> AssignParameterVisitor::operator()(const T&) const;
37// /// for each of the parameter types in ParameterVariant
38// void instantiate_AssignParameterVisitor_operator() __attribute__((unused));
39// void instantiate_AssignParameterVisitor_operator()
40// {
41// ModuleParamList moduleParamList;
42// const std::string name = "";
43// ParameterVariant value;
44// AssignParameterVisitor psv(&moduleParamList, name);
45// boost::apply_visitor(psv, value);
46// }
47// }
48// }
49// Does the same as above but explicit. The above however reacts to changes in the variant automatically.
50// Make explicit template instances for each of the parameter types in FilterParamVariant
51template void AssignParameterVisitor::operator()(const bool&) const;
52template void AssignParameterVisitor::operator()(const int&) const;
53template void AssignParameterVisitor::operator()(const double&) const;
54template void AssignParameterVisitor::operator()(const std::string&) const;
55template void AssignParameterVisitor::operator()(const std::vector<double>&) const;
56template void AssignParameterVisitor::operator()(const std::vector<std::string>&) const;
57
The Module parameter list class.
A single parameter of the module.
Definition: ModuleParam.h:34
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Abstract base class for different kinds of events.
void operator()(const T &t) const
Function call that receives the parameter value from the boost::variant with the correct type.
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::...
ModuleParamList * m_moduleParamList
Parameter list which contains the parameter to be set.
std::string m_paramName
Name of the parameter to be set.