casa
$Rev:20696$
|
An expression executable as function. More...
#include <FuncExpression.h>
Public Member Functions | |
FuncExpression () | |
Construct an empty executable expression. | |
FuncExpression (const String &prog) | |
Construct an executable expression from the given string. | |
FuncExpression (const FuncExpression &other) | |
Make this object a (deep) copy of other. | |
FuncExpression & | operator= (const FuncExpression &other) |
Make this object a (deep) copy of other. | |
~FuncExpression () | |
Destructor. | |
Bool | create (const String &prog) |
Create an executable program. | |
const String & | errorMessage () |
Get the current error message. | |
const vector < FuncExprData::ExprOperator > & | getCode () const |
Get the executable program. | |
uInt | getNpar () const |
Get the number of parameters in executable program. | |
uInt | getNdim () const |
Get the number of dimensions of executable program. | |
const vector < FuncExprData::ExprOperator > & | getCode () |
Get reference to the compiled program. | |
const vector< Double > & | getConst () |
Get reference to compiled constants. | |
Bool | exec (Double &res) const |
Execute the program. | |
void | print (ostream &os) const |
Print the stack information (mainly for debugging) | |
Private Member Functions | |
Bool | compStmt (MUString &prg) |
Compile a statement (in prg, which will be adjusted) | |
Bool | compExpr (MUString &prg) |
Compile an expression (in prg, which will be adjusted) | |
Bool | compTerm (MUString &prg) |
Compile a term (in prg, which will be adjusted) | |
Bool | setOp (FuncExprData::ExprOperator &oper) |
Save an operation on compilation RP stack. | |
Bool | setVal (const Double &val) |
Save a value on constant stack. | |
Bool | setCode (const FuncExprData::ExprOperator &oper) |
Save an executable code. | |
void | initState () |
Initialise the state. | |
Private Attributes | |
FuncExprData | exd |
The expression data /// later into a singleton. | |
String | error_p |
The latest error message. | |
vector < FuncExprData::ExprOperator > | code_p |
The executable code stack (a vector, since it is a re-usable stack) | |
vector < FuncExprData::ExprOperator > | rps_p |
The reverse Polish work stack (a vector, since deque did not work on gcc) | |
FuncExprData::ExprCompState | state_p |
The current state of the compilation. | |
vector< Double > | const_p |
The current constant stack. | |
uInt | npar_p |
The number of parameters in code. | |
uInt | ndim_p |
The number of dimensions of expression. | |
vector< Double > | exec_p |
Executing stack. |
An expression executable as function.
Public interface
This class acts as an interface between a program given as a string (e.g. from a command line interface) and a Function class. The grammar of the language use to express the function is given below. The FuncEXpression
can be used in all places where Functions can be used (like in the linear and non-linear Fitting classes.
An expression is created by either supplying a String
to a constructor, or be setting a String
.
To tie the Glish language to non-linear fitting procedures
Definition at line 84 of file FuncExpression.h.
Construct an empty executable expression.
casa::FuncExpression::FuncExpression | ( | const String & | prog | ) | [explicit] |
Construct an executable expression from the given string.
casa::FuncExpression::FuncExpression | ( | const FuncExpression & | other | ) |
Make this object a (deep) copy of other.
casa::FuncExpression::~FuncExpression | ( | ) | [inline] |
Destructor.
Definition at line 99 of file FuncExpression.h.
Bool casa::FuncExpression::compExpr | ( | MUString & | prg | ) | [private] |
Compile an expression (in prg, which will be adjusted)
Bool casa::FuncExpression::compStmt | ( | MUString & | prg | ) | [private] |
Compile a statement (in prg, which will be adjusted)
Bool casa::FuncExpression::compTerm | ( | MUString & | prg | ) | [private] |
Compile a term (in prg, which will be adjusted)
Bool casa::FuncExpression::create | ( | const String & | prog | ) |
Create an executable program.
const String& casa::FuncExpression::errorMessage | ( | ) | [inline] |
Bool casa::FuncExpression::exec | ( | Double & | res | ) | const |
Execute the program.
const vector<FuncExprData::ExprOperator>& casa::FuncExpression::getCode | ( | ) | const |
Get the executable program.
const vector<FuncExprData::ExprOperator>& casa::FuncExpression::getCode | ( | ) | [inline] |
Get reference to the compiled program.
Definition at line 113 of file FuncExpression.h.
References code_p.
const vector<Double>& casa::FuncExpression::getConst | ( | ) | [inline] |
Get reference to compiled constants.
Definition at line 115 of file FuncExpression.h.
References const_p.
uInt casa::FuncExpression::getNdim | ( | ) | const [inline] |
Get the number of dimensions of executable program.
Definition at line 111 of file FuncExpression.h.
References ndim_p.
uInt casa::FuncExpression::getNpar | ( | ) | const [inline] |
Get the number of parameters in executable program.
Definition at line 109 of file FuncExpression.h.
References npar_p.
void casa::FuncExpression::initState | ( | ) | [private] |
Initialise the state.
FuncExpression& casa::FuncExpression::operator= | ( | const FuncExpression & | other | ) |
Make this object a (deep) copy of other.
void casa::FuncExpression::print | ( | ostream & | os | ) | const |
Print the stack information (mainly for debugging)
Bool casa::FuncExpression::setCode | ( | const FuncExprData::ExprOperator & | oper | ) | [private] |
Save an executable code.
Bool casa::FuncExpression::setOp | ( | FuncExprData::ExprOperator & | oper | ) | [private] |
Save an operation on compilation RP stack.
Bool casa::FuncExpression::setVal | ( | const Double & | val | ) | [private] |
Save a value on constant stack.
vector<FuncExprData::ExprOperator> casa::FuncExpression::code_p [private] |
The executable code stack (a vector, since it is a re-usable stack)
Definition at line 128 of file FuncExpression.h.
Referenced by getCode().
vector<Double> casa::FuncExpression::const_p [private] |
The current constant stack.
Definition at line 134 of file FuncExpression.h.
Referenced by getConst().
String casa::FuncExpression::error_p [mutable, private] |
The latest error message.
Definition at line 126 of file FuncExpression.h.
Referenced by errorMessage().
FuncExprData casa::FuncExpression::exd [private] |
The expression data /// later into a singleton.
Definition at line 124 of file FuncExpression.h.
vector<Double> casa::FuncExpression::exec_p [mutable, private] |
Executing stack.
Definition at line 140 of file FuncExpression.h.
uInt casa::FuncExpression::ndim_p [private] |
The number of dimensions of expression.
Definition at line 138 of file FuncExpression.h.
Referenced by getNdim().
uInt casa::FuncExpression::npar_p [private] |
The number of parameters in code.
Definition at line 136 of file FuncExpression.h.
Referenced by getNpar().
vector<FuncExprData::ExprOperator> casa::FuncExpression::rps_p [private] |
The reverse Polish work stack (a vector, since deque did not work on gcc)
Definition at line 130 of file FuncExpression.h.
The current state of the compilation.
Definition at line 132 of file FuncExpression.h.