CMS 3D CMS Logo

ExpressionVar.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_ExpressionVar_h
2 #define CommonTools_Utils_ExpressionVar_h
3 
4 /* \class reco::parser::ExpressionVar
5  *
6  * Variable expression
7  *
8  * \author original version: Chris Jones, Cornell,
9  * adapted by Luca Lista, INFN
10  *
11  */
12 
16 
17 #include <vector>
18 #include <oneapi/tbb/concurrent_queue.h>
19 
20 namespace reco {
21  namespace parser {
22 
24  class ExpressionVar : public ExpressionBase {
25  private: // Private Data Members
26  std::vector<MethodInvoker> methods_;
27  using Objects = std::vector<std::pair<edm::ObjectWithDict, bool>>;
28  mutable oneapi::tbb::concurrent_queue<Objects> objectsCache_;
30 
31  private: // Private Methods
32  [[nodiscard]] Objects initObjects_() const;
33 
34  Objects borrowObjects() const;
35  void returnObjects(Objects&&) const;
36 
37  public: // Public Static Methods
39 
43 
47  static bool makeStorage(edm::ObjectWithDict& obj, const edm::TypeWithDict& retType);
48 
51  static void delStorage(edm::ObjectWithDict&);
52 
53  public: // Public Methods
54  ExpressionVar(const std::vector<MethodInvoker>& methods, method::TypeCode retType);
56  ~ExpressionVar() override;
57  double value(const edm::ObjectWithDict&) const override;
58  };
59 
63  private: // Private Data Members
64  std::vector<LazyInvoker> methods_;
65 
66  public:
67  ExpressionLazyVar(const std::vector<LazyInvoker>& methods);
68  ~ExpressionLazyVar() override;
69  double value(const edm::ObjectWithDict&) const override;
70  };
71 
72  } // namespace parser
73 } // namespace reco
74 
75 #endif // CommonTools_Utils_ExpressionVar_h
static bool makeStorage(edm::ObjectWithDict &obj, const edm::TypeWithDict &retType)
static double objToDouble(const edm::ObjectWithDict &obj, method::TypeCode type)
method::TypeCode retType_
Definition: ExpressionVar.h:29
ExpressionLazyVar(const std::vector< LazyInvoker > &methods)
ExpressionVar(const std::vector< MethodInvoker > &methods, method::TypeCode retType)
std::vector< std::pair< edm::ObjectWithDict, bool > > Objects
Definition: ExpressionVar.h:27
static bool isValidReturnType(method::TypeCode)
Objects borrowObjects() const
std::vector< MethodInvoker > methods_
Definition: ExpressionVar.h:26
void returnObjects(Objects &&) const
double value(const edm::ObjectWithDict &) const override
static void delStorage(edm::ObjectWithDict &)
double value(const edm::ObjectWithDict &) const override
Evaluate an object&#39;s method or datamember (or chain of them) to get a number.
Definition: ExpressionVar.h:24
fixed size matrix
oneapi::tbb::concurrent_queue< Objects > objectsCache_
Definition: ExpressionVar.h:28
Objects initObjects_() const
std::vector< LazyInvoker > methods_
Definition: ExpressionVar.h:64