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  EvaluatorBase(const EvaluatorBase&) = delete;
61 
62  const EvaluatorBase& operator=(const EvaluatorBase&) = delete;
63 
64  private:
65  // ---------- member data --------------------------------
66  unsigned int m_precedence;
67  };
68  } // namespace formula
69 } // namespace reco
70 
71 #endif
virtual double evaluate(double const *iVariables, double const *iParameters) const =0
virtual std::vector< std::string > abstractSyntaxTree() const =0
std::vector< std::string > shiftAST(std::vector< std::string > child)
const EvaluatorBase & operator=(const EvaluatorBase &)=delete
fixed size matrix