#include <vebMathExpr.h>
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. | |
Base * | copy (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< ROperation > | m_operation |
RVar ** | m_vararray |
RFunction ** | m_funcarray |
int | m_varsSize |
int | m_functionsSize |
Definition at line 47 of file vebMathExpr.h.
typedef std::map<tString, float *> vValue::Expr::Bindings::MathExpr::varmap_t |
typedef std::map<tString, float ((*)(float)) vValue::Expr::Bindings::MathExpr::funcmap_t) |
vValue::Expr::Bindings::MathExpr::MathExpr | ( | tString const & | expr | ) |
Constructs a new MathExpr without variables and functions and the like.
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) {}
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.
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 }
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 }
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
Reimplemented from vValue::Expr::Core::Base.
Definition at line 76 of file vebMathExpr.cpp.
References MathExpr().
00076 { 00077 return new MathExpr(*this); 00078 }
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 }
boost::shared_ptr<ROperation> vValue::Expr::Bindings::MathExpr::m_operation [private] |
RVar** vValue::Expr::Bindings::MathExpr::m_vararray [private] |
int vValue::Expr::Bindings::MathExpr::m_varsSize [private] |
int vValue::Expr::Bindings::MathExpr::m_functionsSize [private] |