CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DetectorDescription/ExprAlgo/interface/ClhepEvaluator.h

Go to the documentation of this file.
00001 #ifndef ClhepEvaluator_h
00002 #define ClhepEvaluator_h
00003 
00004 
00005 #include <vector>
00006 #include <string>
00007 #include "DetectorDescription/ExprAlgo/interface/ExprEvalInterface.h"
00008 #include "CLHEP/Evaluator/Evaluator.h"
00009 
00010 
00011 class ClhepEvaluator : public ExprEvalInterface
00012 {
00013 public:
00014  ClhepEvaluator();
00015   
00016   ~ClhepEvaluator();
00017   
00018   void set(const std::string & ns, const std::string & name, const std::string & exprValue);
00019    
00020   double eval(const std::string & ns, const std::string & expr);
00021   
00022   bool isDefined(const std::string & ns, //< current namespace
00023                  const std::string & name //< name of the variable inside current namespace
00024                  );
00025 
00027   const std::vector<std::string> & variables() const { return variables_;}
00028   const std::vector<std::string> & values() const { return values_;}
00029   
00031 
00032   double eval(const char * expression);
00033   
00035   void set(const std::string & name, const std::string & value);
00036   
00037   void clear();
00038 
00039 private:
00040   void prepare(const std::string & ns,         // input
00041                const std::string & name,       // input
00042                const std::string & exprValue,  // input
00043                std::string & nameResult,       // output
00044                std::string & valResult) const; // output
00045                
00046   void throwex(const std::string & ns, 
00047                const std::string & name, 
00048                const std::string & expr,
00049                const std::string & reason,
00050                int idx=0) const;
00051                
00052   void checkname(const std::string & name) const;              
00053   
00054   HepTool::Evaluator evaluator_;        
00055   std::vector<std::string> variables_;
00056   std::vector<std::string> values_;         
00057 };
00058 
00059 #endif