File indexing completed on 2024-04-06 12:01:19
0001 #ifndef CommonTools_Utils_ExpressionVar_h
0002 #define CommonTools_Utils_ExpressionVar_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "CommonTools/Utils/interface/parser/ExpressionBase.h"
0014 #include "CommonTools/Utils/interface/parser/MethodInvoker.h"
0015 #include "CommonTools/Utils/interface/TypeCode.h"
0016
0017 #include <vector>
0018 #include <oneapi/tbb/concurrent_queue.h>
0019
0020 namespace reco {
0021 namespace parser {
0022
0023
0024 class ExpressionVar : public ExpressionBase {
0025 private:
0026 std::vector<MethodInvoker> methods_;
0027 using Objects = std::vector<std::pair<edm::ObjectWithDict, bool>>;
0028 mutable oneapi::tbb::concurrent_queue<Objects> objectsCache_;
0029 method::TypeCode retType_;
0030
0031 private:
0032 [[nodiscard]] Objects initObjects_() const;
0033
0034 Objects borrowObjects() const;
0035 void returnObjects(Objects&&) const;
0036
0037 public:
0038 static bool isValidReturnType(method::TypeCode);
0039
0040
0041
0042 static double objToDouble(const edm::ObjectWithDict& obj, method::TypeCode type);
0043
0044
0045
0046
0047 static bool makeStorage(edm::ObjectWithDict& obj, const edm::TypeWithDict& retType);
0048
0049
0050
0051 static void delStorage(edm::ObjectWithDict&);
0052
0053 public:
0054 ExpressionVar(const std::vector<MethodInvoker>& methods, method::TypeCode retType);
0055 ExpressionVar(const ExpressionVar&);
0056 ~ExpressionVar() override;
0057 double value(const edm::ObjectWithDict&) const override;
0058 };
0059
0060
0061
0062 class ExpressionLazyVar : public ExpressionBase {
0063 private:
0064 std::vector<LazyInvoker> methods_;
0065
0066 public:
0067 ExpressionLazyVar(const std::vector<LazyInvoker>& methods);
0068 ~ExpressionLazyVar() override;
0069 double value(const edm::ObjectWithDict&) const override;
0070 };
0071
0072 }
0073 }
0074
0075 #endif