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);
35  {
36 
37  public:
38  enum class Precedence {
39  kIdentity = 1,
40  kComparison=2,
41  kPlusMinus = 3,
42  kMultDiv = 4,
43  kPower = 5,
44  kFunction = 6, //default
45  kParenthesis = 7,
47  };
48 
49  EvaluatorBase();
51  virtual ~EvaluatorBase();
52 
53  // ---------- const member functions ---------------------
54  //inputs are considered to be 'arrays' which have already been validated to
55  // be of the appropriate length
56  virtual double evaluate(double const* iVariables, double const* iParameters) const = 0;
57  virtual std::vector<std::string> abstractSyntaxTree() const = 0;
58 
59  unsigned int precedence() const { return m_precedence; }
60  void setPrecedenceToParenthesis() { m_precedence = static_cast<unsigned int>(Precedence::kParenthesis); }
61 
62  private:
63  EvaluatorBase(const EvaluatorBase&) = delete;
64 
65  const EvaluatorBase& operator=(const EvaluatorBase&) = delete;
66 
67  // ---------- member data --------------------------------
68  unsigned int m_precedence;
69  };
70  }
71 }
72 
73 
74 #endif
std::vector< std::string > shiftAST(std::vector< std::string > child)
const EvaluatorBase & operator=(const EvaluatorBase &)=delete
virtual std::vector< std::string > abstractSyntaxTree() const =0
virtual double evaluate(double const *iVariables, double const *iParameters) const =0
unsigned int precedence() const
fixed size matrix