00001 #ifndef CommonTools_Utils_ExpressionVar_h 00002 #define CommonTools_Utils_ExpressionVar_h 00003 /* \class reco::parser::ExpressionVar 00004 * 00005 * Variable expression 00006 * 00007 * \author original version: Chris Jones, Cornell, 00008 * adapted to Reflex by Luca Lista, INFN 00009 * 00010 * \version $Revision: 1.4 $ 00011 * 00012 */ 00013 #include "CommonTools/Utils/src/ExpressionBase.h" 00014 #include "CommonTools/Utils/src/TypeCode.h" 00015 #include "CommonTools/Utils/src/MethodInvoker.h" 00016 #include <vector> 00017 00018 namespace reco { 00019 namespace parser { 00021 struct ExpressionVar : public ExpressionBase { 00022 ExpressionVar(const std::vector<MethodInvoker> & methods, method::TypeCode retType); 00023 00024 ~ExpressionVar() ; 00025 ExpressionVar(const ExpressionVar &var) ; 00026 00027 virtual double value(const Reflex::Object & o) const; 00028 00029 static bool isValidReturnType(method::TypeCode); 00032 static double objToDouble(const Reflex::Object &obj, method::TypeCode type) ; 00033 00037 static bool makeStorage(Reflex::Object &obj, const Reflex::Member &member) ; 00040 static void delStorage(Reflex::Object &obj); 00041 00042 private: 00043 std::vector<MethodInvoker> methods_; 00044 mutable std::vector<Reflex::Object> objects_; 00045 mutable std::vector<bool> needsDestructor_; 00046 method::TypeCode retType_; 00047 static void trueDelete(Reflex::Object & o) ; 00048 void initObjects_(); 00049 }; 00050 00053 struct ExpressionLazyVar : public ExpressionBase { 00054 ExpressionLazyVar(const std::vector<LazyInvoker> & methods); 00055 ~ExpressionLazyVar() ; 00056 00057 virtual double value(const Reflex::Object & o) const; 00058 00059 private: 00060 std::vector<LazyInvoker> methods_; 00061 mutable std::vector<Reflex::Object> objects_; 00062 }; 00063 00064 } 00065 } 00066 00067 #endif