Belle II Software  release-05-02-19
ModuleParam.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/core/ModuleParamBase.h>
13 
14 #include <string>
15 
16 namespace boost {
17  namespace python {
18  namespace api {
19  class object;
20  }
21  using api::object;
22  }
23 }
24 
25 namespace Belle2 {
35  template <class T>
36  class ModuleParam : public ModuleParamBase {
37 
38  public:
45  static std::string TypeInfo();
46 
58  explicit ModuleParam(T& paramVariable, const std::string& description = "", bool force = false);
59 
63  virtual ~ModuleParam();
64 
70  void setValue(const T& value);
71 
77  void setDefaultValue(const T& defaultValue);
78 
84  T& getValue();
85 
91  T& getDefaultValue();
92 
102  virtual void setValueFromPythonObject(const boost::python::object& pyObject) final;
103 
110  virtual void
111  setValueToPythonObject(boost::python::object& pyObject, bool defaultValues = false) const final;
112 
114  virtual void setValueFromParam(const ModuleParamBase& param) final;
115 
119  void resetValue();
120 
121  private:
124 
127  };
129 } // end of Belle2 namespace
Belle2::ModuleParam::setValueFromParam
virtual void setValueFromParam(const ModuleParamBase &param) final
Set value from other ModuleParam of same type.
Definition: ModuleParam.templateDetails.h:86
Belle2::ModuleParam::resetValue
void resetValue()
Resets the parameter value by assigning the default value to the parameter value.
Definition: ModuleParam.templateDetails.h:97
Belle2::ModuleParam::ModuleParam
ModuleParam(T &paramVariable, const std::string &description="", bool force=false)
Constructor.
Definition: ModuleParam.templateDetails.h:38
Belle2::ModuleParam::setDefaultValue
void setDefaultValue(const T &defaultValue)
Sets the default value of a parameter.
Definition: ModuleParam.templateDetails.h:52
Belle2::ModuleParam::getValue
T & getValue()
Returns the value of the parameter.
Definition: ModuleParam.templateDetails.h:60
Belle2::ModuleParam::TypeInfo
static std::string TypeInfo()
Static function to generate a string description for the parameter type.
Definition: ModuleParam.templateDetails.h:32
Belle2::ModuleParam::m_paramVariable
T & m_paramVariable
Reference to the member variable in the module which stores the parameter value.
Definition: ModuleParam.h:126
Belle2::ModuleParam::setValueFromPythonObject
virtual void setValueFromPythonObject(const boost::python::object &pyObject) final
Implements a method for setting boost::python objects.
Definition: ModuleParam.templateDetails.h:72
Belle2::ModuleParam::getDefaultValue
T & getDefaultValue()
Returns the default value of the parameter.
Definition: ModuleParam.templateDetails.h:66
Belle2::ModuleParam::~ModuleParam
virtual ~ModuleParam()
Destructor.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ModuleParam::setValueToPythonObject
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.
Definition: ModuleParam.templateDetails.h:78
Belle2::ModuleParam::setValue
void setValue(const T &value)
Sets the value of a parameter.
Definition: ModuleParam.templateDetails.h:45
Belle2::ModuleParam::m_defaultValue
T m_defaultValue
The default value of the parameter.
Definition: ModuleParam.h:123