stx::BasicSymbolTable Class Reference

Class representing variables and functions placeholders within an expression. More...

#include <ExpressionParser.h>

Inheritance diagram for stx::BasicSymbolTable:

stx::SymbolTable List of all members.

Public Types

typedef AnyScalar(*) functionptr_type (const paramlist_type &paramlist)
 Signature of a function used in the symbol table.

Public Member Functions

 BasicSymbolTable ()
 Fills in the functionmap with the standard functions.
virtual ~BasicSymbolTable ()
 Required for virtual functions.
virtual AnyScalar lookupVariable (const std::string &varname) const
 Return the (constant) value of a variable.
virtual AnyScalar processFunction (const std::string &funcname, const paramlist_type &paramlist) const
 Called when a program-defined function needs to be evaluated within an expression.
void setVariable (const std::string &varname, const AnyScalar &value)
 Add or replace a variable to the symbol table.
void setFunction (const std::string &funcname, int arguments, functionptr_type funcptr)
 Add or replace a function to the symbol table.
void clearVariables ()
 Clear variables table.
void clearFunctions ()
 Clear function table.
void addStandardFunctions ()
 Add set of standard mathematic functions.

Protected Types

typedef std::map< std::string,
AnyScalar
variablemap_type
 Container used to save a map of variable names.
typedef std::map< std::string,
struct FunctionInfo
functionmap_type
 Container used to save a map of function names.

Static Protected Member Functions

static AnyScalar funcPI (const paramlist_type &paramlist)
 Return the value of PI as a double AnyScalar.
static AnyScalar funcSIN (const paramlist_type &paramlist)
 Return the value of sin(x) as a double AnyScalar.
static AnyScalar funcCOS (const paramlist_type &paramlist)
 Return the value of cos(x) as a double AnyScalar.
static AnyScalar funcTAN (const paramlist_type &paramlist)
 Return the value of tan(x) as a double AnyScalar.
static AnyScalar funcABS (const paramlist_type &paramlist)
 Return the value of abs(x) or fabs(f).
static AnyScalar funcEXP (const paramlist_type &paramlist)
 Return the value of exp(x) as a double AnyScalar.
static AnyScalar funcLOGN (const paramlist_type &paramlist)
 Return the value of log(x) as a double AnyScalar.
static AnyScalar funcPOW (const paramlist_type &paramlist)
 Return the value of pow(x,y) as a double AnyScalar.
static AnyScalar funcSQRT (const paramlist_type &paramlist)
 Return the value of sqrt(x) as a double AnyScalar.

Private Attributes

variablemap_type variablemap
 Variable map which can be filled by the user-application.
functionmap_type functionmap
 Function map used to lookup standard or user-added function.

Classes

struct  FunctionInfo
 Extra info about a function: the valid arguments. More...

Detailed Description

Class representing variables and functions placeholders within an expression.

This base class contain two tables of variables and functions. Variables may be filled into the STL map by the program. The class also contains a set of basic mathematic functions.

Definition at line 163 of file ExpressionParser.h.


Member Function Documentation

AnyScalar stx::BasicSymbolTable::lookupVariable ( const std::string &  varname  )  const [virtual]

Return the (constant) value of a variable.

In this basic implementation no variables are defined, it always throws an UnknownSymbolException.

Implements stx::SymbolTable.

Definition at line 1532 of file ExpressionParser.cc.

References variablemap.

AnyScalar stx::BasicSymbolTable::processFunction ( const std::string &  funcname,
const paramlist_type paramlist 
) const [virtual]

Called when a program-defined function needs to be evaluated within an expression.

Implements stx::SymbolTable.

Definition at line 1547 of file ExpressionParser.cc.

References functionmap.


The documentation for this class was generated from the following files:
Generated on Tue Jul 17 16:51:58 2007 for STX Expression Parser by  doxygen 1.5.2