Belle II Software  release-05-02-19
SelectionVariable.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 
15 // is expanded as the string value for X
16 #define STRING_NAME(X) #X
17 // is expanded as the function "static const std::string name(void)" which returns the string value of Y
18 #define PUT_NAME_FUNCTION(Y) static const std::string name(void) {return STRING_NAME(Y); };
19 
20 #include <string>
21 #include <functional>
22 
23 namespace Belle2 {
53  template <class templateArgumentType, size_t Nargs, class templateReturnType = double>
55 
63  template <size_t n , class returnType, class parameterType, class ... Ts>
64  struct FunctionOf {
66  typedef typename FunctionOf < n - 1, returnType, parameterType,
67  parameterType, Ts... >::functionType functionType;
68  };
69 
74  template <class returnType, class parameterType, class ... Ts>
75  struct FunctionOf<0, returnType, parameterType, Ts...> {
77  typedef std::function<returnType(Ts...)> functionType;
78  };
79 
80  public:
81 
83  typedef templateReturnType variableType;
84 
86  typedef templateArgumentType argumentType;
87 
89  typedef typename FunctionOf<Nargs, variableType,
91 
93  static const size_t c_Nargs = Nargs;
94 
101  inline static variableType
102  value(const templateArgumentType& arg1, const templateArgumentType& arg2);
103 
105  virtual ~SelectionVariable() {};
106 
109 
110  };
111 
113 #define SELECTION_VARIABLE( variableName, nArgs, argumentType, implementation ) \
114  class variableName: \
115  public SelectionVariable< argumentType , nArgs, double > \
116  { \
117  public: \
118  static const std::string name(void) {return #variableName; }; \
119  implementation \
120  }; \
121 
122 
123 }
Belle2::SelectionVariable::~SelectionVariable
virtual ~SelectionVariable()
A bogus virtual denstructor.
Definition: SelectionVariable.h:105
Belle2::SelectionVariable::variableType
templateReturnType variableType
Type of the returned object.
Definition: SelectionVariable.h:83
Belle2::SelectionVariable::c_Nargs
static const size_t c_Nargs
Number of arguments.
Definition: SelectionVariable.h:93
Belle2::SelectionVariable::SelectionVariable
SelectionVariable()
A bogus constructor.
Definition: SelectionVariable.h:108
Belle2::SelectionVariable::FunctionOf::functionType
FunctionOf< n - 1, returnType, parameterType, parameterType, Ts... >::functionType functionType
Handy typedef for the functionType.
Definition: SelectionVariable.h:67
Belle2::SelectionVariable::FunctionOf< 0, returnType, parameterType, Ts... >::functionType
std::function< returnType(Ts...)> functionType
Handy typedef for the functionType.
Definition: SelectionVariable.h:77
Belle2::SelectionVariable< PointContainerType, 0, int >::functionType
FunctionOf< Nargs, variableType, const argumentType & >::functionType functionType
Type of the function returning the value.
Definition: SelectionVariable.h:90
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SelectionVariable::value
static variableType value(const templateArgumentType &arg1, const templateArgumentType &arg2)
Static method that return the variable associated to:
Belle2::SelectionVariable
Base class of the selection variable objects used for pair filtering.
Definition: SelectionVariable.h:54
Belle2::SelectionVariable::FunctionOf
this struct is an internal utility.
Definition: SelectionVariable.h:64
Belle2::SelectionVariable::argumentType
templateArgumentType argumentType
Type of the argument object.
Definition: SelectionVariable.h:86