CMS 3D CMS Logo

formulaEvaluatorBase.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_formulaEvaluatorBase_h
2 #define CommonTools_Utils_formulaEvaluatorBase_h
3 // -*- C++ -*-
4 //
5 // Package: CommonTools/Utils
6 // Class : reco::formula::EvaluatorBase
7 //
18 //
19 // Original Author: Christopher Jones
20 // Created: Wed, 23 Sep 2015 16:26:00 GMT
21 //
22 
23 // system include files
24 #include <vector>
25 #include <string>
26 
27 // user include files
28 
29 // forward declarations
30 
31 namespace reco {
32  namespace formula {
33  std::vector<std::string> shiftAST(std::vector<std::string> child);
34  class EvaluatorBase {
35  public:
36  enum class Precedence {
37  kIdentity = 1,
38  kComparison = 2,
39  kPlusMinus = 3,
40  kMultDiv = 4,
41  kPower = 5,
42  kFunction = 6, //default
43  kParenthesis = 7,
45  };
46 
47  EvaluatorBase();
49  virtual ~EvaluatorBase();
50 
51  // ---------- const member functions ---------------------
52  //inputs are considered to be 'arrays' which have already been validated to
53  // be of the appropriate length
54  virtual double evaluate(double const* iVariables, double const* iParameters) const = 0;
55  virtual std::vector<std::string> abstractSyntaxTree() const = 0;
56 
57  unsigned int precedence() const { return m_precedence; }
58  void setPrecedenceToParenthesis() { m_precedence = static_cast<unsigned int>(Precedence::kParenthesis); }
59 
60  private:
61  EvaluatorBase(const EvaluatorBase&) = delete;
62 
63  const EvaluatorBase& operator=(const EvaluatorBase&) = delete;
64 
65  // ---------- member data --------------------------------
66  unsigned int m_precedence;
67  };
68  } // namespace formula
69 } // namespace reco
70 
71 #endif
reco::formula::EvaluatorBase::~EvaluatorBase
virtual ~EvaluatorBase()
Definition: formulaEvaluatorBase.cc:34
reco::formula::EvaluatorBase::operator=
const EvaluatorBase & operator=(const EvaluatorBase &)=delete
reco::formula::EvaluatorBase
Definition: formulaEvaluatorBase.h:34
reco::formula::EvaluatorBase::setPrecedenceToParenthesis
void setPrecedenceToParenthesis()
Definition: formulaEvaluatorBase.h:58
reco::formula::EvaluatorBase::EvaluatorBase
EvaluatorBase()
Definition: formulaEvaluatorBase.cc:30
reco::formula::EvaluatorBase::precedence
unsigned int precedence() const
Definition: formulaEvaluatorBase.h:57
reco::formula::EvaluatorBase::Precedence::kIdentity
pfMETCorrectionType0_cfi.formula
formula
Definition: pfMETCorrectionType0_cfi.py:46
reco::formula::EvaluatorBase::Precedence
Precedence
Definition: formulaEvaluatorBase.h:36
reco::formula::EvaluatorBase::Precedence::kParenthesis
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::formula::EvaluatorBase::m_precedence
unsigned int m_precedence
Definition: formulaEvaluatorBase.h:66
reco::formula::EvaluatorBase::Precedence::kUnaryMinusOperator
reco::formula::EvaluatorBase::Precedence::kFunction
reco::formula::EvaluatorBase::evaluate
virtual double evaluate(double const *iVariables, double const *iParameters) const =0
reco::formula::shiftAST
std::vector< std::string > shiftAST(std::vector< std::string > child)
Definition: formulaEvaluatorBase.cc:36
reco::formula::EvaluatorBase::abstractSyntaxTree
virtual std::vector< std::string > abstractSyntaxTree() const =0
reco::formula::EvaluatorBase::Precedence::kPower
reco::formula::EvaluatorBase::Precedence::kPlusMinus
child
Definition: simpleInheritance.h:11
reco::formula::EvaluatorBase::Precedence::kComparison
reco::formula::EvaluatorBase::Precedence::kMultDiv