Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:23

0001 #ifndef ClhepEvaluator_h
0002 #define ClhepEvaluator_h
0003 
0004 #include <vector>
0005 #include <string>
0006 #include "CLHEP/Evaluator/Evaluator.h"
0007 
0008 class ClhepEvaluator {
0009 public:
0010   ClhepEvaluator();
0011 
0012   ~ClhepEvaluator();
0013 
0014   void set(const std::string& ns, const std::string& name, const std::string& exprValue);
0015 
0016   double eval(const std::string& ns, const std::string& expr);
0017 
0018   bool isDefined(const std::string& ns,   //< current namespace
0019                  const std::string& name  //< name of the variable inside current namespace
0020   );
0021 
0022   //! access to the clhep-implementation of the dictionary variables
0023   const std::vector<std::string>& variables() const { return variables_; }
0024   const std::vector<std::string>& values() const { return values_; }
0025 
0026   //! evaluations using directly the CLHEP-evaluator
0027   /** expression must be an expression compatible with the CLHEP-Evaluator syntax */
0028   double eval(const char* expression);
0029 
0030   //! filling the clhep-implementation of the dictionary
0031   void set(const std::string& name, const std::string& value);
0032 
0033   void clear();
0034 
0035 private:
0036   void prepare(const std::string& ns,          // input
0037                const std::string& name,        // input
0038                const std::string& exprValue,   // input
0039                std::string& nameResult,        // output
0040                std::string& valResult) const;  // output
0041 
0042   void throwex(const std::string& ns,
0043                const std::string& name,
0044                const std::string& expr,
0045                const std::string& reason,
0046                int idx = 0) const;
0047 
0048   void checkname(const std::string& name) const;
0049 
0050   HepTool::Evaluator evaluator_;
0051   std::vector<std::string> variables_;
0052   std::vector<std::string> values_;
0053 };
0054 
0055 #endif