Belle II Software  release-08-01-10
ModuleParam.h
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 #pragma once
9 
10 #include <framework/core/ModuleParamBase.h>
11 
12 #include <string>
13 
14 namespace boost {
15  namespace python {
16  namespace api {
17  class object;
18  }
19  using api::object;
20  }
21 }
22 
23 namespace Belle2 {
33  template <class T>
34  class ModuleParam : public ModuleParamBase {
35 
36  public:
43  static std::string TypeInfo();
44 
56  explicit ModuleParam(T& paramVariable, const std::string& description = "", bool force = false);
57 
61  virtual ~ModuleParam();
62 
68  void setValue(const T& value);
69 
75  void setDefaultValue(const T& defaultValue);
76 
82  T& getValue();
83 
89  T& getDefaultValue();
90 
100  virtual void setValueFromPythonObject(const boost::python::object& pyObject) final;
101 
108  virtual void
109  setValueToPythonObject(boost::python::object& pyObject, bool defaultValues = false) const final;
110 
112  virtual void setValueFromParam(const ModuleParamBase& param) final;
113 
117  void resetValue();
118 
119  private:
122 
125  };
127 } // end of Belle2 namespace
Base class for module parameter.
A single parameter of the module.
Definition: ModuleParam.h:34
T & m_paramVariable
Reference to the member variable in the module which stores the parameter value.
Definition: ModuleParam.h:124
T m_defaultValue
The default value of the parameter.
Definition: ModuleParam.h:121
virtual void setValueFromPythonObject(const boost::python::object &pyObject) final
Implements a method for setting boost::python objects.
ModuleParam(T &paramVariable, const std::string &description="", bool force=false)
Constructor.
virtual void setValueToPythonObject(boost::python::object &pyObject, bool defaultValues=false) const final
Returns a python object containing the value or the default value of the given parameter.
void resetValue()
Resets the parameter value by assigning the default value to the parameter value.
T & getDefaultValue()
Returns the default value of the parameter.
static std::string TypeInfo()
Static function to generate a string description for the parameter type.
virtual ~ModuleParam()
Destructor.
T & getValue()
Returns the value of the parameter.
void setDefaultValue(const T &defaultValue)
Sets the default value of a parameter.
void setValue(const T &value)
Sets the value of a parameter.
virtual void setValueFromParam(const ModuleParamBase &param) final
Set value from other ModuleParam of same type.
Abstract base class for different kinds of events.