C++ main module for gpm Package  1.0
MATH_RootExpression.h
Go to the documentation of this file.
1 #ifndef MATH_RootExpression_H
2 #define MATH_RootExpression_H
3 
5 #include "CORE_Exception.h"
6 
7 #include "MATH_Environment.h"
8 #include "MATH_Variable.h"
21 
25  SP_OBJECT(MATH_RootExpression);
26  // ATTRIBUTES
27 
28 
29 private:
30 
31  SP::MATH_Variable mValue;
32 
33 protected:
34  // METHODS
35 
36  // CONSTRUCTORS
37 
40  MATH_RootExpression(void);
41 
42 
43 
44  // DESTRUCTORS
45 
46 
49  virtual ~MATH_RootExpression(void);
50 
51 
52 public:
53 
56  static inline SP::MATH_RootExpression New() {
57  SP::MATH_RootExpression p(new MATH_RootExpression(),MATH_RootExpression::Delete());
58  p->setThis(p);
59  return p;
60  }
61 
62  //OPERATOR
63 
64  inline const double& operator[](const int& index) const {
65  return (*mValue.get())[index];
66  }
67 
68 
69  // SET methods
70 
71 
72 
73  // GET methods
74 
77  inline const double* getValues() const {
78  return &(*mValue.get())[0];
79  }
82  inline const double& getValue(const int& index) const {
83  return (*mValue.get())[index];
84  }
85 
86 
87  // GET methods
90  virtual const MATH_RootExpression* getRootNode() const {
91  return this;
92  }
93 public:
94  // OTHERS methods
97  virtual int evaluate(const tFlag& action,MATH_Environment& symbols,MATH_Variable& var) const {
98  return MATH_ParentExpression::evaluate(action,symbols,var);
99  }
102  virtual double evaluate() {
103  SP::MATH_Environment env=MATH_Environment::New();
104  return evaluate(ALGEBRIC,*env.get());
105  }
108  virtual double evaluate(MATH_Environment& env) {
109  return evaluate(ALGEBRIC,env);
110  }
113  virtual double evaluate(SP::MATH_Environment env) {
114  if (env.get()!=null) return evaluate(ALGEBRIC,*env.get());
115  return evaluate();
116  }
119  virtual double evaluate(const tFlag& action) {
120  SP::MATH_Environment env=MATH_Environment::New();
121  return evaluate(action,*env.get());
122  }
125  virtual double evaluate(const tFlag& action,MATH_Environment& symbols) {
126  evaluate(action,symbols,*mValue.get());
127  return (*mValue.get())[0];
128  }
131  virtual double evaluate(const tFlag& action,SP::MATH_Environment symbols) {
132  if (symbols.get()!=null) return evaluate(action,*symbols.get());
133  else return evaluate(action);
134  }
135 
136 
145  tBoolean parse(const tString& expr,MATH_Environment& symbols);
146 
155  tBoolean parse(const tString& expr) {
156  SP::MATH_Environment env=MATH_Environment::New();
157  return parse(expr,*env.get());
158  }
159 
169  tString parse(const tString& expr,MATH_Environment& env,int& retCode);
170 
173  virtual SP::MATH_ExpressionClassFactory newClassFactoryInstance() const;
174 
177  virtual tString toString() const;
178 
179 private:
182  void replaceEPowerByTenPower(tString& expr) const;
185  void deleteBlanks(tString& expr) const;
186 };
187 
188 #endif
virtual double evaluate(MATH_Environment &env)
void evaluate the expression
Definition: MATH_RootExpression.h:108
virtual double evaluate(const tFlag &action, SP::MATH_Environment symbols)
void evaluate the expression
Definition: MATH_RootExpression.h:131
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
tBoolean parse(const tString &expr, MATH_Environment &symbols)
parse the string
Definition: MATH_RootExpression.cpp:65
static SP::MATH_RootExpression New()
create a root expression
Definition: MATH_RootExpression.h:56
tBoolean parse(const tString &expr)
parse the string
Definition: MATH_RootExpression.h:155
This class is a node of expression tree with is a parent and a child.
Definition: MATH_NodeExpression.h:18
virtual int evaluate(const tFlag &action, MATH_Environment &symbols, MATH_Variable &var) const
void evaluate the expression
Definition: MATH_ParentExpression.h:163
virtual SP::MATH_ExpressionClassFactory newClassFactoryInstance() const
create a class factory for leaves or operators
Definition: MATH_RootExpression.cpp:15
#define tBoolean
Definition: types.h:35
this class describes a class factory to generate MATH_Expression classes. The nodes lists are initial...
Definition: MATH_ExpressionClassFactory.h:22
virtual double evaluate()
void evaluate the expression
Definition: MATH_RootExpression.h:102
virtual double evaluate(SP::MATH_Environment env)
void evaluate the expression
Definition: MATH_RootExpression.h:113
#define null
Definition: types.h:13
DEFINE_SVPTR(MATH_RootExpression)
This class is a root expression The MATH_RootExpression::newClassFactoryInstance() creates the class ...
Definition: MATH_RootExpression.h:24
const double * getValues() const
get the values
Definition: MATH_RootExpression.h:77
DEFINE_SPTR(MATH_ExpressionClassFactory)
virtual int evaluate(const tFlag &action, MATH_Environment &symbols, MATH_Variable &var) const
void evaluate the expression
Definition: MATH_RootExpression.h:97
virtual double evaluate(const tFlag &action)
void evaluate the expression
Definition: MATH_RootExpression.h:119
const double & operator[](const int &index) const
Definition: MATH_RootExpression.h:64
This class describes a parent of math expression tree. A parent have arguments:
Definition: MATH_ParentExpression.h:22
static SP::MATH_Environment New()
create a node expression
Definition: MATH_Environment.h:50
virtual tString toString() const
return the string representation
Definition: MATH_RootExpression.cpp:120
#define tString
Definition: types.h:36
virtual const MATH_RootExpression * getRootNode() const
return the root node of the node
Definition: MATH_RootExpression.h:90
This class decribes an environment class.
Definition: MATH_Environment.h:14
virtual double evaluate(const tFlag &action, MATH_Environment &symbols)
void evaluate the expression
Definition: MATH_RootExpression.h:125
MATH_RootExpression(void)
create
Definition: MATH_RootExpression.cpp:7
const double & getValue(const int &index) const
get the values
Definition: MATH_RootExpression.h:82
virtual ~MATH_RootExpression(void)
destroy
Definition: MATH_RootExpression.cpp:11
static const tFlag ALGEBRIC
Definition: MATH_Expression.h:31
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14