CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Evaluator.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: Evaluator.h,v 1.1.1.1.12.1 2010/06/28 15:34:31 garren Exp $
00003 // ---------------------------------------------------------------------------
00004 
00005 #ifndef HEP_EVALUATOR_H
00006 #define HEP_EVALUATOR_H
00007 
00008 #include <string>
00009 
00010 namespace HepTool {
00011 
00026 class Evaluator {
00027  public: 
00028 
00039   enum {
00040     OK,                         
00041     WARNING_EXISTING_VARIABLE,  
00042     WARNING_EXISTING_FUNCTION,  
00043     WARNING_BLANK_STRING,       
00044     ERROR_NOT_A_NAME,           
00045     ERROR_SYNTAX_ERROR,         
00046     ERROR_UNPAIRED_PARENTHESIS, 
00047     ERROR_UNEXPECTED_SYMBOL,    
00048     ERROR_UNKNOWN_VARIABLE,     
00049     ERROR_UNKNOWN_FUNCTION,     
00050     ERROR_EMPTY_PARAMETER,      
00051     ERROR_CALCULATION_ERROR     
00052   };
00053 
00057   Evaluator();
00058 
00062   ~Evaluator(); 
00063 
00076   double evaluate(const char * expression);
00077 
00081   int status() const;
00082 
00086   int error_position() const; 
00087 
00091   void print_error() const;
00095   std::string error_name() const;
00096 
00105   void setVariable(const char * name, double value);
00106 
00116   void setVariable(const char * name, const char * expression);
00117 
00126   void setFunction(const char * name, double (*fun)());
00127 
00136   void setFunction(const char * name, double (*fun)(double));
00137 
00146   void setFunction(const char * name, double (*fun)(double,double));
00147 
00156   void setFunction(const char * name, double (*fun)(double,double,double));
00157 
00166   void setFunction(const char * name,
00167                    double (*fun)(double,double,double,double));
00168 
00177   void setFunction(const char * name,
00178                    double (*fun)(double,double,double,double,double));
00179 
00186   bool findVariable(const char * name) const;
00187 
00195   bool findFunction(const char * name, int npar) const;
00196 
00202   void removeVariable(const char * name);
00203 
00210   void removeFunction(const char * name, int npar);
00211 
00215   void clear();
00216 
00220   void setStdMath();
00221 
00248   void setSystemOfUnits(double meter    = 1.0,
00249                         double kilogram = 1.0,
00250                         double second   = 1.0,
00251                         double ampere   = 1.0,
00252                         double kelvin   = 1.0,
00253                         double mole     = 1.0,
00254                         double candela  = 1.0);
00255 
00256 private: 
00257   void * p;                                 // private data 
00258   Evaluator(const Evaluator &);             // copy constructor is not allowed
00259   Evaluator & operator=(const Evaluator &); // assignment is not allowed
00260 };
00261 
00262 } // namespace HepTool
00263 
00264 #endif /* HEP_EVALUATOR_H */

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7