CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CommonTools/Utils/src/ExpressionVar.h

Go to the documentation of this file.
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 by Luca Lista, INFN
00009  *
00010  * \version $Revision: 1.7 $
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 edm::ObjectWithDict & o) const;
00028 
00029       static bool isValidReturnType(method::TypeCode);
00032       static double objToDouble(const edm::ObjectWithDict &obj, method::TypeCode type) ;
00033 
00037       static bool makeStorage(edm::ObjectWithDict &obj, const edm::TypeWithDict &retType) ;
00040       static void delStorage(edm::ObjectWithDict &obj);
00041 
00042     private:
00043       std::vector<MethodInvoker>  methods_;
00044       mutable std::vector<edm::ObjectWithDict> objects_;
00045       mutable std::vector<bool>           needsDestructor_;
00046       method::TypeCode retType_;
00047       void initObjects_();
00048     }; 
00049 
00052   struct ExpressionLazyVar : public ExpressionBase {
00053       ExpressionLazyVar(const std::vector<LazyInvoker> & methods);
00054       ~ExpressionLazyVar() ;
00055 
00056       virtual double value(const edm::ObjectWithDict & o) const;
00057 
00058     private:
00059       std::vector<LazyInvoker> methods_;
00060       mutable std::vector<edm::ObjectWithDict> objects_;
00061   }; 
00062 
00063  }
00064 }
00065 
00066 #endif