1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef CommonTools_Utils_formulaFunctionOneArgEvaluator_h
#define CommonTools_Utils_formulaFunctionOneArgEvaluator_h
// -*- C++ -*-
//
// Package: CommonTools/Utils
// Class : formulaFunctionOneArgEvaluator
//
/**\class reco::formula::FunctionOneArgEvaluator formulaFunctionOneArgEvaluator.h "formulaFunctionOneArgEvaluator.h"
Description: [one line class summary]
Usage:
<usage>
*/
//
// Original Author: Christopher Jones
// Created: Wed, 23 Sep 2015 17:41:33 GMT
//
// system include files
#include <memory>
#include <functional>
// user include files
#include "formulaEvaluatorBase.h"
// forward declarations
namespace reco {
namespace formula {
class FunctionOneArgEvaluator : public EvaluatorBase {
public:
template <typename T>
explicit FunctionOneArgEvaluator(std::shared_ptr<EvaluatorBase> iArg, T iFunc)
: m_arg(std::move(iArg)), m_function(iFunc) {}
// ---------- const member functions ---------------------
double evaluate(double const* iVariables, double const* iParameters) const final {
return m_function(m_arg->evaluate(iVariables, iParameters));
}
std::vector<std::string> abstractSyntaxTree() const final {
auto ret = shiftAST(m_arg->abstractSyntaxTree());
ret.emplace(ret.begin(), "func 1 arg");
return ret;
}
FunctionOneArgEvaluator(const FunctionOneArgEvaluator&) = delete;
const FunctionOneArgEvaluator& operator=(const FunctionOneArgEvaluator&) = delete;
private:
// ---------- member data --------------------------------
std::shared_ptr<EvaluatorBase> m_arg;
std::function<double(double)> m_function;
};
} // namespace formula
} // namespace reco
#endif
|