C++ main module for gpm Package  1.0
MATH_LeafExpression.h
Go to the documentation of this file.
1 #ifndef MATH_LeafExpression_H
2 #define MATH_LeafExpression_H
3 
4 #include "MATH_ChildExpression.h"
5 #include "CORE_String.h"
6 
8 
9 
32  // ATTRIBUTES
33 
34 private:
35 
36  tString mSymbol;
37 
38 protected:
39  // METHODS
40 
41  // CONSTRUCTORS
42 
45  MATH_LeafExpression(void);
46 
47 
48 
49  // DESTRUCTORS
50 
51 
54  virtual ~MATH_LeafExpression(void);
55 
56 
57 private:
58 
59 public:
62  static inline SP::MATH_LeafExpression New() {
63  SP::MATH_LeafExpression p(new MATH_LeafExpression(),MATH_LeafExpression::Delete());
64  p->setThis(p);
65  return p;
66  }
69  static inline SP::MATH_LeafExpression New(const tString& symbol) {
70  SP::MATH_LeafExpression p=New();
71  p->setSymbol(symbol);
72  return p;
73  }
74 
75 
76  // SET methods
77 
80  virtual void copy(const MATH_LeafExpression& l) {
81  setSymbol(l.getSymbol());
82  }
83 
86  inline void setSymbol(const tString& tag) {
87  mSymbol=tag;
88  CORE_String::trim(mSymbol);
89  }
90 
91 
92 
93  // GET methods
96  inline tString getSymbol() const {
97  return mSymbol;
98  }
99 
100 
104  return true;
105  }
106 
107 public:
108  // OTHERS methods
127  virtual int evaluate(const tFlag& action,MATH_Environment& symbols,MATH_Variable& var) const;
128 
151  virtual MATH_ChildExpression* insertInTree(MATH_Expression* tree,MATH_Environment& symbols,tString& expr);
152 
153 
154 
157  virtual tString toString() const;
158 
159 private:
162  int getValue(const tString& symbol,double* values,int& size,tFlag& type) const;
163 
164 };
165 
166 #endif
static SP::MATH_LeafExpression New(const tString &symbol)
create a leaf expression
Definition: MATH_LeafExpression.h:69
#define DEFINE_SPTR(X)
Definition: CORE_Pointers.h:164
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
This class is the base class of a math expression.
Definition: MATH_Expression.h:24
void trim()
trim
Definition: CORE_String.h:605
#define tBoolean
Definition: types.h:35
virtual MATH_ChildExpression * insertInTree(MATH_Expression *tree, MATH_Environment &symbols, tString &expr)
insert the node This in tree & erase the This corresponding character in expr
Definition: MATH_BinaryOperator.cpp:54
static SP::MATH_LeafExpression New()
create a leaf expression
Definition: MATH_LeafExpression.h:62
virtual int evaluate(const tFlag &action, MATH_Environment &symbols, MATH_Variable &var) const
void evaluate the expression
Definition: MATH_NodeExpression.h:96
This class is a leaf of math expression ie either double float long double etc... ...
Definition: MATH_LeafExpression.h:30
#define SP_OBJECT(X)
Definition: CORE_Pointers.h:176
virtual void copy(const MATH_LeafExpression &l)
copy the leaf
Definition: MATH_LeafExpression.h:80
virtual tString toString() const
return the string representation of the class
Definition: MATH_BinaryOperator.cpp:86
virtual tBoolean isEnvironmentVariableNode() const
return true if the node is a variable to add to environment
Definition: MATH_LeafExpression.h:103
tString getSymbol() const
get the symbol
Definition: MATH_LeafExpression.h:96
This class decribes a binary operator.
Definition: MATH_BinaryOperator.h:15
This class is a children of a parent expression.
Definition: MATH_ChildExpression.h:23
void setSymbol(const tString &tag)
set the symbol
Definition: MATH_LeafExpression.h:86
#define tString
Definition: types.h:36
This class decribes an environment class.
Definition: MATH_Environment.h:14
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14