Belle II Software  release-08-01-10
SelectionVariable.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 
9 #pragma once
10 
11 
13 // is expanded as the string value for X
14 #define STRING_NAME(X) #X
15 // is expanded as the function "static const std::string name(void)" which returns the string value of Y
16 #define PUT_NAME_FUNCTION(Y) static const std::string name(void) {return STRING_NAME(Y); };
17 
18 #include <string>
19 #include <functional>
20 
21 namespace Belle2 {
51  template <class templateArgumentType, size_t Nargs, class templateReturnType = double>
53 
61  template <size_t n, class returnType, class parameterType, class ... Ts>
62  struct FunctionOf {
64  typedef typename FunctionOf < n - 1, returnType, parameterType,
65  parameterType, Ts... >::functionType functionType;
66  };
67 
72  template <class returnType, class parameterType, class ... Ts>
73  struct FunctionOf<0, returnType, parameterType, Ts...> {
75  typedef std::function<returnType(Ts...)> functionType;
76  };
77 
78  public:
79 
81  typedef templateReturnType variableType;
82 
84  typedef templateArgumentType argumentType;
85 
87  typedef typename FunctionOf<Nargs, variableType,
89 
91  static const size_t c_Nargs = Nargs;
92 
99  inline static variableType
100  value(const templateArgumentType& arg1, const templateArgumentType& arg2);
101 
103  virtual ~SelectionVariable() {};
104 
107 
108  };
109 
111 #define SELECTION_VARIABLE( variableName, nArgs, argumentType, implementation ) \
112  class variableName: \
113  public SelectionVariable< argumentType , nArgs, double > \
114  { \
115  public: \
116  static const std::string name(void) {return #variableName; }; \
117  implementation \
118  }; \
119 
121 }
Base class of the selection variable objects used for pair filtering.
SelectionVariable()
A bogus constructor.
templateArgumentType argumentType
Type of the argument object.
virtual ~SelectionVariable()
A bogus virtual denstructor.
static variableType value(const templateArgumentType &arg1, const templateArgumentType &arg2)
Static method that return the variable associated to:
static const size_t c_Nargs
Number of arguments.
FunctionOf< Nargs, variableType, const argumentType & >::functionType functionType
Type of the function returning the value.
templateReturnType variableType
Type of the returned object.
Abstract base class for different kinds of events.
std::function< returnType(Ts...)> functionType
Handy typedef for the functionType.
this struct is an internal utility.
FunctionOf< n - 1, returnType, parameterType, parameterType, Ts... >::functionType functionType
Handy typedef for the functionType.