00001
00002
00003
00004
00005 #ifndef HEP_EVALUATOR_H
00006 #define HEP_EVALUATOR_H
00007
00008 #include "CLHEP/config/CLHEP.h"
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;
00092
00101 void setVariable(const char * name, double value);
00102
00112 void setVariable(const char * name, const char * expression);
00113
00122 void setFunction(const char * name, double (*fun)());
00123
00132 void setFunction(const char * name, double (*fun)(double));
00133
00142 void setFunction(const char * name, double (*fun)(double,double));
00143
00152 void setFunction(const char * name, double (*fun)(double,double,double));
00153
00162 void setFunction(const char * name,
00163 double (*fun)(double,double,double,double));
00164
00173 void setFunction(const char * name,
00174 double (*fun)(double,double,double,double,double));
00175
00182 bool findVariable(const char * name) const;
00183
00191 bool findFunction(const char * name, int npar) const;
00192
00198 void removeVariable(const char * name);
00199
00206 void removeFunction(const char * name, int npar);
00207
00211 void clear();
00212
00216 void setStdMath();
00217
00244 void setSystemOfUnits(double meter = 1.0,
00245 double kilogram = 1.0,
00246 double second = 1.0,
00247 double ampere = 1.0,
00248 double kelvin = 1.0,
00249 double mole = 1.0,
00250 double candela = 1.0);
00251
00252 private:
00253 void * p;
00254 Evaluator(const Evaluator &);
00255 Evaluator & operator=(const Evaluator &);
00256 };
00257
00258 }
00259
00260 #endif