Geant4-11
Evaluator.h
Go to the documentation of this file.
1// -*- C++ -*-
2// ---------------------------------------------------------------------------
3
4#ifndef HEP_EVALUATOR_H
5#define HEP_EVALUATOR_H
6
7#include <string>
8
9namespace HepTool {
10
25class Evaluator {
26 public:
27
38 enum {
51 };
52
56 Evaluator();
57
61 ~Evaluator();
62
75 double evaluate(const char * expression);
76
80 int status() const;
81
85 int error_position() const;
86
90 void print_error() const;
94 std::string error_name() const;
95
104 void setVariable(const char * name, double value);
105
115 void setVariable(const char * name, const char * expression);
116
125 void setFunction(const char * name, double (*fun)());
126
135 void setFunction(const char * name, double (*fun)(double));
136
145 void setFunction(const char * name, double (*fun)(double,double));
146
155 void setFunction(const char * name, double (*fun)(double,double,double));
156
165 void setFunction(const char * name,
166 double (*fun)(double,double,double,double));
167
176 void setFunction(const char * name,
177 double (*fun)(double,double,double,double,double));
178
185 bool findVariable(const char * name) const;
186
194 bool findFunction(const char * name, int npar) const;
195
201 void removeVariable(const char * name);
202
209 void removeFunction(const char * name, int npar);
210
214 void clear();
215
219 void setStdMath();
220
247 void setSystemOfUnits(double meter = 1.0,
248 double kilogram = 1.0,
249 double second = 1.0,
250 double ampere = 1.0,
251 double kelvin = 1.0,
252 double mole = 1.0,
253 double candela = 1.0);
254
255private:
256 void * p; // private data
257 Evaluator(const Evaluator &); // copy constructor is not allowed
258 Evaluator & operator=(const Evaluator &); // assignment is not allowed
259};
260
261} // namespace HepTool
262
263#endif /* HEP_EVALUATOR_H */
static constexpr double kelvin
Definition: G4SIunits.hh:274
static constexpr double ampere
Definition: G4SIunits.hh:174
static constexpr double candela
Definition: G4SIunits.hh:310
static constexpr double kilogram
Definition: G4SIunits.hh:162
static constexpr double mole
Definition: G4SIunits.hh:279
static constexpr double meter
Definition: G4SIunits.hh:62
static constexpr double second
Definition: G4SIunits.hh:137
int error_position() const
Definition: Evaluator.cc:638
bool findFunction(const char *name, int npar) const
Definition: Evaluator.cc:734
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)
void print_error() const
Definition: Evaluator.cc:643
double evaluate(const char *expression)
Definition: Evaluator.cc:613
std::string error_name() const
Definition: Evaluator.cc:652
Evaluator & operator=(const Evaluator &)
void removeVariable(const char *name)
Definition: Evaluator.cc:745
void removeFunction(const char *name, int npar)
Definition: Evaluator.cc:754
void setFunction(const char *name, double(*fun)())
Definition: Evaluator.cc:698
void setVariable(const char *name, double value)
Definition: Evaluator.cc:689
int status() const
Definition: Evaluator.cc:633
bool findVariable(const char *name) const
Definition: Evaluator.cc:723
Evaluator(const Evaluator &)
@ ERROR_UNPAIRED_PARENTHESIS
Definition: Evaluator.h:45
const char * name(G4int ptype)