vValue::Expr::Bindings::MathExpr Class Reference

Stores a math expression using the mathexpr library. More...

#include <vebMathExpr.h>

Inheritance diagram for vValue::Expr::Bindings::MathExpr:

Inheritance graph
[legend]
Collaboration diagram for vValue::Expr::Bindings::MathExpr:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::map< tString,
float * > 
varmap_t
 map of variable names and their references
typedef std::map< tString,
float((*)(float)) 
funcmap_t )
 map of function names and their references

Public Member Functions

 MathExpr (tString const &expr)
 Constructs a new MathExpr without variables and functions and the like.
 MathExpr (tString const &expr, varmap_t const &vars, funcmap_t const &functions)
 Constructs a new MathExpr with an array of variables and functions.
Basecopy (void) const
 Returns an exact copy of this object.
 ~MathExpr (void)
virtual Variant GetValue (void) const
 Returns the value in its native format.

Private Attributes

boost::shared_ptr< ROperationm_operation
RVar ** m_vararray
RFunction ** m_funcarray
int m_varsSize
int m_functionsSize


Detailed Description

Stores a math expression using the mathexpr library.

Definition at line 47 of file vebMathExpr.h.


Member Typedef Documentation

typedef std::map<tString, float *> vValue::Expr::Bindings::MathExpr::varmap_t

map of variable names and their references

Definition at line 49 of file vebMathExpr.h.

typedef std::map<tString, float ((*)(float)) vValue::Expr::Bindings::MathExpr::funcmap_t)

map of function names and their references

Definition at line 50 of file vebMathExpr.h.


Constructor & Destructor Documentation

vValue::Expr::Bindings::MathExpr::MathExpr ( tString const &  expr  ) 

Constructs a new MathExpr without variables and functions and the like.

Parameters:
expr The expression to be parsed

Definition at line 38 of file vebMathExpr.cpp.

Referenced by copy().

00038 : m_operation(new ROperation(expr.c_str())), m_vararray(0), m_funcarray(0), m_varsSize(0), m_functionsSize(0) {}

Here is the caller graph for this function:

vValue::Expr::Bindings::MathExpr::MathExpr ( tString const &  expr,
varmap_t const &  vars,
funcmap_t const &  functions 
)

Constructs a new MathExpr with an array of variables and functions.

Parameters:
expr The expression to be parsed
vars A map of variable names and their references
functions A map of function names and their references

Definition at line 43 of file vebMathExpr.cpp.

References m_funcarray, m_functionsSize, m_operation, m_vararray, m_varsSize, and RFunction::SetName().

00043                                                                                         {
00044     // what a mess. why can't this darn library just use stl functions? :s
00045     m_vararray = new RVar*[vars.size()];
00046     unsigned int i = 0;
00047     for(varmap_t::const_iterator iter = vars.begin(); iter != vars.end(); ++iter, ++i) {
00048         m_vararray[i] = new RVar(iter->first.c_str(), iter->second);
00049     }
00050     m_funcarray = new RFunction*[functions.size()];
00051     unsigned int j = 0;
00052     m_varsSize = vars.size();
00053     m_functionsSize = functions.size();
00054     for(funcmap_t::const_iterator iter = functions.begin(); iter != functions.end(); ++iter, ++j) {
00055         m_funcarray[j] = new RFunction(iter->second);
00056         m_funcarray[j]->SetName(iter->first.c_str());
00057     }
00058     m_operation = boost::shared_ptr<ROperation>(new ROperation(expr.c_str(), vars.size(), m_vararray, functions.size(), m_funcarray));
00059 }

Here is the call graph for this function:

vValue::Expr::Bindings::MathExpr::~MathExpr ( void   ) 

Definition at line 61 of file vebMathExpr.cpp.

References m_funcarray, m_functionsSize, m_vararray, and m_varsSize.

00061                     {
00062     if(m_vararray != 0) {
00063         for(int i = 0; i < m_varsSize; i++) {
00064             delete m_vararray[i];
00065         }
00066         delete[] m_vararray;
00067     }
00068     if(m_funcarray != 0) {
00069         for(int i = 0; i < m_functionsSize; i++) {
00070             delete m_funcarray[i];
00071         }
00072         delete[] m_funcarray;
00073     }
00074 }


Member Function Documentation

Base * vValue::Expr::Bindings::MathExpr::copy ( void   )  const [virtual]

Returns an exact copy of this object.

This should be overwritten in any derived class or they will mysteriously vanish if you use the tValue::Set container, for example

Returns:
a pointer to the newly created copy

Reimplemented from vValue::Expr::Core::Base.

Definition at line 76 of file vebMathExpr.cpp.

References MathExpr().

00076                                {
00077     return new MathExpr(*this);
00078 }

Here is the call graph for this function:

Variant vValue::Expr::Bindings::MathExpr::GetValue ( void   )  const [virtual]

Returns the value in its native format.

Reimplemented from vValue::Expr::Core::Base.

Definition at line 80 of file vebMathExpr.cpp.

References m_operation.

00080                                  {
00081     return m_operation->Val();
00082 }


Member Data Documentation

boost::shared_ptr<ROperation> vValue::Expr::Bindings::MathExpr::m_operation [private]

Definition at line 52 of file vebMathExpr.h.

Referenced by GetValue(), and MathExpr().

RVar** vValue::Expr::Bindings::MathExpr::m_vararray [private]

Definition at line 53 of file vebMathExpr.h.

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

RFunction** vValue::Expr::Bindings::MathExpr::m_funcarray [private]

Definition at line 54 of file vebMathExpr.h.

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

int vValue::Expr::Bindings::MathExpr::m_varsSize [private]

Definition at line 55 of file vebMathExpr.h.

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

int vValue::Expr::Bindings::MathExpr::m_functionsSize [private]

Definition at line 55 of file vebMathExpr.h.

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


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:05:30 2008 for Armagetron Advanced by  doxygen 1.5.4