C++ main module for gpm Package  1.0
MATH_FunctionNode.h
Go to the documentation of this file.
1 #ifndef MATH_FunctionNode_H
2 #define MATH_FunctionNode_H
3 
4 #include "MATH_LeafExpression.h"
5 
6 #include "MATH_RootExpression.h"
7 
22  SP_OBJECT(MATH_FunctionNode);
23 
24  // ATTRIBUTES
25 
26 private:
27  //ASSOCIATIONS
28  SV::MATH_RootExpression mArguments;
29 
30 protected:
31  // METHODS
32 
33  // CONSTRUCTORS
34 
37  MATH_FunctionNode(void);
38 
39 
40 
41  // DESTRUCTORS
42 
43 
46  virtual ~MATH_FunctionNode(void);
47 
48 public:
49 
50  // new
51  virtual SP::MATH_FunctionNode newInstance() const=0;
52 
53  // SET
54 
55 
58  inline void addArgument(SP::MATH_RootExpression arg) {
59  mArguments.add(arg);
60  }
61 
62  // GET
66  return false;
67  }
68 
69 
70 
73  inline int getArgumentsNumber() const {
74  return mArguments.getSize();
75  }
78  inline SPC::MATH_RootExpression getArgument(const int& index) const {
79 
80  if (index>=mArguments.getSize()) {
81  SPC::MATH_RootExpression nullArg;
82  return nullArg;
83  }
84  return mArguments[index];
85  }
88  inline SP::MATH_RootExpression getArgument(const int& index) {
89  if (index>=mArguments.getSize()) {
90  SP::MATH_RootExpression nullArg;
91  return nullArg;
92  }
93  return mArguments[index];
94  }
95 
96 
97 
98  // OTHERS methods
99 public:
125 
133  virtual int evaluate(const tFlag& action,MATH_Environment& symbols,MATH_Variable& var) const=0;
134 
140  tString readArguments(const tString& formula,MATH_Environment& symbols);
141 
142 
143 public:
144 
145 
148  virtual tString toString() const;
149 };
150 
151 #endif
DEFINE_SVPTR(MATH_FunctionNode)
void addArgument(SP::MATH_RootExpression arg)
add arguments
Definition: MATH_FunctionNode.h:58
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
tString readArguments(const tString &formula, MATH_Environment &symbols)
read the arguments from formula & add the found symbols in symbols list
Definition: MATH_FunctionNode.cpp:15
This class is the base class of a math expression.
Definition: MATH_Expression.h:24
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_FunctionNode.cpp:62
#define tBoolean
Definition: types.h:35
DEFINE_SPTR(MATH_FunctionNode)
virtual tString toString() const
return the string representation of the class
Definition: MATH_FunctionNode.cpp:74
MATH_FunctionNode(void)
create
Definition: MATH_FunctionNode.cpp:9
virtual ~MATH_FunctionNode(void)
destroy
Definition: MATH_FunctionNode.cpp:12
This class is a leaf of math expression ie either double float long double etc... ...
Definition: MATH_LeafExpression.h:30
virtual SP::MATH_FunctionNode newInstance() const =0
virtual tBoolean isEnvironmentVariableNode() const
return true if the node is a variable to add to environment
Definition: MATH_FunctionNode.h:65
This class is a children of a parent expression.
Definition: MATH_ChildExpression.h:23
virtual int evaluate(const tFlag &action, MATH_Environment &symbols, MATH_Variable &var) const =0
void evaluate the expression
SP::MATH_RootExpression getArgument(const int &index)
get argument at index
Definition: MATH_FunctionNode.h:88
#define tString
Definition: types.h:36
This class decribes an environment class.
Definition: MATH_Environment.h:14
This class decribes a function.
Definition: MATH_FunctionNode.h:21
int getArgumentsNumber() const
get the arguments number
Definition: MATH_FunctionNode.h:73
#define tFlag
Definition: types.h:14
SPC::MATH_RootExpression getArgument(const int &index) const
get argument at index
Definition: MATH_FunctionNode.h:78