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
61
62
63
64
|
#ifndef CommonTools_Utils_formulaFunctionTwoArgsEvaluator_h
#define CommonTools_Utils_formulaFunctionTwoArgsEvaluator_h
// -*- C++ -*-
//
// Package: CommonTools/Utils
// Class : formulaFunctionTwoArgsEvaluator
//
/**\class reco::formula::FunctionTwoArgsEvaluator formulaFunctionTwoArgsEvaluator.h "formulaFunctionTwoArgsEvaluator.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 FunctionTwoArgsEvaluator : public EvaluatorBase {
public:
template <typename T>
FunctionTwoArgsEvaluator(std::shared_ptr<EvaluatorBase> iArg1, std::shared_ptr<EvaluatorBase> iArg2, T iFunc)
: m_arg1(std::move(iArg1)), m_arg2(std::move(iArg2)), m_function(iFunc) {}
// ---------- const member functions ---------------------
double evaluate(double const* iVariables, double const* iParameters) const final {
return m_function(m_arg1->evaluate(iVariables, iParameters), m_arg2->evaluate(iVariables, iParameters));
}
std::vector<std::string> abstractSyntaxTree() const final {
auto ret = shiftAST(m_arg1->abstractSyntaxTree());
for (auto& v : shiftAST(m_arg2->abstractSyntaxTree())) {
ret.emplace_back(std::move(v));
}
ret.emplace(ret.begin(), "func 2 args");
return ret;
}
FunctionTwoArgsEvaluator(const FunctionTwoArgsEvaluator&) = delete;
const FunctionTwoArgsEvaluator& operator=(const FunctionTwoArgsEvaluator&) = delete;
private:
// ---------- member data --------------------------------
std::shared_ptr<EvaluatorBase> m_arg1;
std::shared_ptr<EvaluatorBase> m_arg2;
std::function<double(double, double)> m_function;
};
} // namespace formula
} // namespace reco
#endif
|