CDataFunc Class Reference

#include <DataFunc.h>

Collaboration diagram for CDataFunc:

Collaboration graph
[legend]

List of all members.


Detailed Description

GreyLab function parser and evaluator.

Reads, parses and interprets human readable Infix functions into a Reverse Polish Notation for execution and performs the operations on data.

Definition at line 47 of file DataFunc.h.


Public Types

enum  status {
  OK, NONENDING_VAR, UNKNOWN_TAG, UNMATCHED_PARENTHESES,
  NONENDING_OP, TOO_FEW_VARS, INVALID_SEPARATOR
}

Public Member Functions

 CDataFunc ()
 Initialise CDataFunc.
 ~CDataFunc ()
 Destruct CDataFunc.
status InfixToRPN (char *input)
 Converts a infix string into RPN stack.
double Evaluate (double x, double y, double z, int cols, double coldata[])
 Evaluates an RPN stack.

Public Attributes

bool valid
 Valid function?

Private Member Functions

int FindTagID (char *string)
 Searches the list of tokens for a particular tag.
status TestEvaluate (void)
 Simple evaluation check.

Private Attributes

struct CDataFunc::tokenqueue
 RPN token entry.
real * values
 List of values.
int nValues
 Number of values.
int nQueue
 Number of tokens in the list.

Static Private Attributes

static opops = NULL
 The list of useable operators.
static int nOps = 0
 Number of operators.
static int instances = 0
 Instances of this class (for cleanup handling).

Classes

struct  op
 Mathematical operator details. More...
struct  token
 RPN token entry. More...

Member Enumeration Documentation

enum CDataFunc::status

Enumerator:
OK 
NONENDING_VAR 
UNKNOWN_TAG 
UNMATCHED_PARENTHESES 
NONENDING_OP 
TOO_FEW_VARS 
INVALID_SEPARATOR 

Definition at line 50 of file DataFunc.h.


Constructor & Destructor Documentation

CDataFunc::CDataFunc (  ) 

Initialise CDataFunc.

If there are no instances of the class then the array of available operators is built.

Definition at line 59 of file DataFunc.cpp.

References BUILDOP, instances, nOps, nQueue, nValues, ops, queue, valid, and values.

CDataFunc::~CDataFunc (  ) 

Destruct CDataFunc.

If this is the last instances of the class then delete the array of available operators.

Definition at line 124 of file DataFunc.cpp.

References instances, nOps, ops, queue, and values.


Member Function Documentation

int CDataFunc::FindTagID ( char *  string  )  [private]

Searches the list of tokens for a particular tag.

Parameters:
string Name of the operator to search for.
Returns:
ID of the found tag or -1 if not found.

Definition at line 146 of file DataFunc.cpp.

References nOps, and ops.

Referenced by InfixToRPN().

Here is the caller graph for this function:

CDataFunc::status CDataFunc::TestEvaluate ( void   )  [private]

Simple evaluation check.

Checks that after evaluation we are just left with the answer on the stack.

Returns:
Status of the test evaluation as a CDataFunc::status.

Definition at line 681 of file DataFunc.cpp.

References CDataFunc::op::args, nQueue, OK, ops, queue, CDataFunc::token::tagid, TOO_FEW_VARS, and valid.

Referenced by InfixToRPN().

Here is the caller graph for this function:

CDataFunc::status CDataFunc::InfixToRPN ( char *  input  ) 

Converts a infix string into RPN stack.

Parameters:
input Input equation.
Remarks:
The resulting RPN stack is in the array CDataFunc::queue.
Returns:
Error code of the parsing as a CDataFunc::status.

Definition at line 164 of file DataFunc.cpp.

References FindTagID(), INVALID_SEPARATOR, CDataFunc::op::lassociative, CDataFunc::token::next, NONNUMBER, nQueue, nValues, ops, CDataFunc::op::precedence, CDataFunc::token::prev, queue, CDataFunc::token::tagid, TestEvaluate(), UNKNOWN_TAG, UNMATCHED_PARENTHESES, valid, CDataFunc::token::value, and values.

Referenced by DrawPaletteDialog::cmdUpdateAllData(), and GreyLabWindow::renderObjects().

Here is the call graph for this function:

Here is the caller graph for this function:

double CDataFunc::Evaluate ( double  x,
double  y,
double  z,
int  cols,
double  coldata[] 
)

Evaluates an RPN stack.

Evaluates the RPN stack in CDataFunc::queue.

Parameters:
x X coordinate of the datapoint.
y Y coordinate of the datapoint.
z Z value of the datapoint.
cols Number of columns in coldata.
coldata Values in the other columns of the datapoint.
Returns:
Evaluated value.

Definition at line 450 of file DataFunc.cpp.

References nQueue, queue, CDataFunc::token::value, and values.

Referenced by GreyLabWindow::cmdDAProcess(), and GreyLabWindow::renderObjects().

Here is the caller graph for this function:


Member Data Documentation

CDataFunc::op * CDataFunc::ops = NULL [static, private]

The list of useable operators.

List of operators.

Definition at line 60 of file DataFunc.h.

Referenced by CDataFunc(), FindTagID(), InfixToRPN(), TestEvaluate(), and ~CDataFunc().

int CDataFunc::nOps = 0 [static, private]

Number of operators.

Number of operators

Definition at line 61 of file DataFunc.h.

Referenced by CDataFunc(), FindTagID(), and ~CDataFunc().

struct CDataFunc::token * CDataFunc::queue [private]

RPN token entry.

Linked list of tokens

Referenced by CDataFunc(), Evaluate(), InfixToRPN(), TestEvaluate(), and ~CDataFunc().

int CDataFunc::instances = 0 [static, private]

Instances of this class (for cleanup handling).

Number of instances of this class.

Definition at line 74 of file DataFunc.h.

Referenced by CDataFunc(), and ~CDataFunc().


The documentation for this class was generated from the following files:
Generated on Mon Mar 10 13:55:45 2008 for GreyLab by  doxygen 1.5.3