casacore
Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::FuncExpression Class Reference

More...

#include <FuncExpression.h>

Public Member Functions

 FuncExpression ()
 Construct an empty executable expression. More...
 
 FuncExpression (const String &prog)
 Construct an executable expression from the given string. More...
 
 FuncExpression (const FuncExpression &other)
 Make this object a (deep) copy of other. More...
 
FuncExpressionoperator= (const FuncExpression &other)
 Make this object a (deep) copy of other. More...
 
 ~FuncExpression ()
 Destructor. More...
 
Bool create (const String &prog)
 Create an executable program. More...
 
const StringerrorMessage ()
 Get the current error message. More...
 
const vector< FuncExprData::ExprOperator > & getCode () const
 Get the executable program. More...
 
uInt getNpar () const
 Get the number of parameters in executable program. More...
 
uInt getNdim () const
 Get the number of dimensions of executable program. More...
 
const vector< FuncExprData::ExprOperator > & getCode ()
 Get reference to the compiled program. More...
 
const vector< Double > & getConst ()
 Get reference to compiled constants. More...
 
Bool exec (Double &res) const
 Execute the program. More...
 
void print (ostream &os) const
 Print the stack information (mainly for debugging) More...
 

Private Member Functions

Bool compStmt (MUString &prg)
 Compile a statement (in prg, which will be adjusted) More...
 
Bool compExpr (MUString &prg)
 Compile an expression (in prg, which will be adjusted) More...
 
Bool compTerm (MUString &prg)
 Compile a term (in prg, which will be adjusted) More...
 
Bool setOp (FuncExprData::ExprOperator &oper)
 Save an operation on compilation RP stack. More...
 
Bool setVal (const Double &val)
 Save a value on constant stack. More...
 
Bool setCode (const FuncExprData::ExprOperator &oper)
 Save an executable code. More...
 
void initState ()
 Initialise the state. More...
 

Private Attributes

FuncExprData exd
 The expression data /// later into a singleton. More...
 
String error_p
 The latest error message. More...
 
vector< FuncExprData::ExprOperatorcode_p
 The executable code stack (a vector, since it is a re-usable stack) More...
 
vector< FuncExprData::ExprOperatorrps_p
 The reverse Polish work stack (a vector, since deque did not work on gcc) More...
 
FuncExprData::ExprCompState state_p
 The current state of the compilation. More...
 
vector< Doubleconst_p
 The current constant stack. More...
 
uInt npar_p
 The number of parameters in code. More...
 
uInt ndim_p
 The number of dimensions of expression. More...
 
vector< Doubleexec_p
 Executing stack. More...
 

Detailed Description

An expression executable as function

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

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.

Example

Motivation

To tie the Glish language to non-linear fitting procedures

Thrown Exceptions

To Do

Definition at line 84 of file FuncExpression.h.

Constructor & Destructor Documentation

◆ FuncExpression() [1/3]

casacore::FuncExpression::FuncExpression ( )

Construct an empty executable expression.

◆ FuncExpression() [2/3]

casacore::FuncExpression::FuncExpression ( const String prog)
explicit

Construct an executable expression from the given string.

◆ FuncExpression() [3/3]

casacore::FuncExpression::FuncExpression ( const FuncExpression other)

Make this object a (deep) copy of other.

◆ ~FuncExpression()

casacore::FuncExpression::~FuncExpression ( )
inline

Destructor.

Definition at line 99 of file FuncExpression.h.

Member Function Documentation

◆ compExpr()

Bool casacore::FuncExpression::compExpr ( MUString prg)
private

Compile an expression (in prg, which will be adjusted)

◆ compStmt()

Bool casacore::FuncExpression::compStmt ( MUString prg)
private

Compile a statement (in prg, which will be adjusted)

◆ compTerm()

Bool casacore::FuncExpression::compTerm ( MUString prg)
private

Compile a term (in prg, which will be adjusted)

◆ create()

Bool casacore::FuncExpression::create ( const String prog)

Create an executable program.

◆ errorMessage()

const String& casacore::FuncExpression::errorMessage ( )
inline

Get the current error message.

Definition at line 105 of file FuncExpression.h.

References error_p.

◆ exec()

Bool casacore::FuncExpression::exec ( Double res) const

Execute the program.

◆ getCode() [1/2]

const vector<FuncExprData::ExprOperator>& casacore::FuncExpression::getCode ( )
inline

Get reference to the compiled program.

Definition at line 113 of file FuncExpression.h.

References code_p.

◆ getCode() [2/2]

const vector<FuncExprData::ExprOperator>& casacore::FuncExpression::getCode ( ) const

Get the executable program.

◆ getConst()

const vector<Double>& casacore::FuncExpression::getConst ( )
inline

Get reference to compiled constants.

Definition at line 115 of file FuncExpression.h.

References const_p.

◆ getNdim()

uInt casacore::FuncExpression::getNdim ( ) const
inline

Get the number of dimensions of executable program.

Definition at line 111 of file FuncExpression.h.

References ndim_p.

◆ getNpar()

uInt casacore::FuncExpression::getNpar ( ) const
inline

Get the number of parameters in executable program.

Definition at line 109 of file FuncExpression.h.

References npar_p.

◆ initState()

void casacore::FuncExpression::initState ( )
private

Initialise the state.

◆ operator=()

FuncExpression& casacore::FuncExpression::operator= ( const FuncExpression other)

Make this object a (deep) copy of other.

◆ print()

void casacore::FuncExpression::print ( ostream &  os) const

Print the stack information (mainly for debugging)

◆ setCode()

Bool casacore::FuncExpression::setCode ( const FuncExprData::ExprOperator oper)
private

Save an executable code.

◆ setOp()

Bool casacore::FuncExpression::setOp ( FuncExprData::ExprOperator oper)
private

Save an operation on compilation RP stack.

◆ setVal()

Bool casacore::FuncExpression::setVal ( const Double val)
private

Save a value on constant stack.

Member Data Documentation

◆ code_p

vector<FuncExprData::ExprOperator> casacore::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().

◆ const_p

vector<Double> casacore::FuncExpression::const_p
private

The current constant stack.

Definition at line 134 of file FuncExpression.h.

Referenced by getConst().

◆ error_p

String casacore::FuncExpression::error_p
mutableprivate

The latest error message.

Definition at line 126 of file FuncExpression.h.

Referenced by errorMessage().

◆ exd

FuncExprData casacore::FuncExpression::exd
private

The expression data /// later into a singleton.

Definition at line 124 of file FuncExpression.h.

◆ exec_p

vector<Double> casacore::FuncExpression::exec_p
mutableprivate

Executing stack.

Definition at line 140 of file FuncExpression.h.

◆ ndim_p

uInt casacore::FuncExpression::ndim_p
private

The number of dimensions of expression.

Definition at line 138 of file FuncExpression.h.

Referenced by getNdim().

◆ npar_p

uInt casacore::FuncExpression::npar_p
private

The number of parameters in code.

Definition at line 136 of file FuncExpression.h.

Referenced by getNpar().

◆ rps_p

vector<FuncExprData::ExprOperator> casacore::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.

◆ state_p

FuncExprData::ExprCompState casacore::FuncExpression::state_p
private

The current state of the compilation.

Definition at line 132 of file FuncExpression.h.


The documentation for this class was generated from the following file: