Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Evaluator.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:$
3 // ---------------------------------------------------------------------------
4 
5 #ifndef HEP_EVALUATOR_H
6 #define HEP_EVALUATOR_H
7 
8 #include <string>
9 
10 namespace HepTool {
11 
26 class Evaluator {
27  public:
28 
39  enum {
40  OK,
52  };
53 
57  Evaluator();
58 
62  ~Evaluator();
63 
76  double evaluate(const char * expression);
77 
81  int status() const;
82 
86  int error_position() const;
87 
91  void print_error() const;
95  std::string error_name() const;
96 
105  void setVariable(const char * name, double value);
106 
116  void setVariable(const char * name, const char * expression);
117 
126  void setFunction(const char * name, double (*fun)());
127 
136  void setFunction(const char * name, double (*fun)(double));
137 
146  void setFunction(const char * name, double (*fun)(double,double));
147 
156  void setFunction(const char * name, double (*fun)(double,double,double));
157 
166  void setFunction(const char * name,
167  double (*fun)(double,double,double,double));
168 
177  void setFunction(const char * name,
178  double (*fun)(double,double,double,double,double));
179 
186  bool findVariable(const char * name) const;
187 
195  bool findFunction(const char * name, int npar) const;
196 
202  void removeVariable(const char * name);
203 
210  void removeFunction(const char * name, int npar);
211 
215  void clear();
216 
220  void setStdMath();
221 
248  void setSystemOfUnits(double meter = 1.0,
249  double kilogram = 1.0,
250  double second = 1.0,
251  double ampere = 1.0,
252  double kelvin = 1.0,
253  double mole = 1.0,
254  double candela = 1.0);
255 
256 private:
257  void * p; // private data
258  Evaluator(const Evaluator &); // copy constructor is not allowed
259  Evaluator & operator=(const Evaluator &); // assignment is not allowed
260 };
261 
262 } // namespace HepTool
263 
264 #endif /* HEP_EVALUATOR_H */
static constexpr double candela
Definition: G4SIunits.hh:317
const XML_Char * name
Definition: expat.h:151
const char * p
Definition: xmltok.h:285
int status() const
Definition: Evaluator.cc:631
bool findFunction(const char *name, int npar) const
Definition: Evaluator.cc:732
static constexpr double ampere
Definition: G4SIunits.hh:189
static constexpr double second
Definition: G4SIunits.hh:157
static constexpr double meter
Definition: G4SIunits.hh:82
void setFunction(const char *name, double(*fun)())
Definition: Evaluator.cc:696
int error_position() const
Definition: Evaluator.cc:636
std::string error_name() const
Definition: Evaluator.cc:650
const XML_Char int const XML_Char * value
Definition: expat.h:331
void print_error() const
Definition: Evaluator.cc:641
double evaluate(const char *expression)
Definition: Evaluator.cc:611
static constexpr double kelvin
Definition: G4SIunits.hh:281
void setVariable(const char *name, double value)
Definition: Evaluator.cc:687
void setSystemOfUnits(double meter=1.0, double kilogram=1.0, double second=1.0, double ampere=1.0, double kelvin=1.0, double mole=1.0, double candela=1.0)
static constexpr double kilogram
Definition: G4SIunits.hh:177
void removeFunction(const char *name, int npar)
Definition: Evaluator.cc:752
bool findVariable(const char *name) const
Definition: Evaluator.cc:721
void removeVariable(const char *name)
Definition: Evaluator.cc:743
static constexpr double mole
Definition: G4SIunits.hh:286