C++ main module for gpm Package  1.0
MATH_BeginBlock.h
Go to the documentation of this file.
1 #ifndef MATH_BeginBlock_H
2 #define MATH_BeginBlock_H
3 
4 #include "MATH_Block.h"
5 
6 class MATH_Operator;
8 
21 class MATH_BeginBlock : public MATH_Block {
22  SP_OBJECT(MATH_BeginBlock);
23 
24  // ATTRIBUTES
25  //ASSOCIATIONS
26 private:
27  SP::MATH_EndBlock mEndBlock;
28 
29 protected:
30  // METHODS
31 
32  // CONSTRUCTORS
33 
36  MATH_BeginBlock(void);
37 
38 
39 
40  // DESTRUCTORS
41 
42 
45  virtual ~MATH_BeginBlock(void);
46 
47 
48 private:
49 
50 public:
53  static inline SP::MATH_BeginBlock New() {
54  SP::MATH_BeginBlock p(new MATH_BeginBlock(),MATH_BeginBlock::Delete());
55  p->setThis(p);
56  return p;
57  }
58 
61  virtual SP::MATH_NodeExpression newInstance() const {
62  return New();
63  }
64 
65 
66 
67  // SET methods
68 
69 
70 
71  // GET methods
72 
73 public:
74  // OTHERS methods
79  virtual tBoolean isCompatible(const MATH_Block& eb) const {
80  const char &bc=getBlockString();
81  const char &ec=eb.getBlockString();
82  return ( ( (bc=='{') && (ec=='}') ) ||
83  ( (bc=='(') && (ec==')') ) ||
84  ( (bc=='[') && (ec==']') )
85  );
86 
87  }
88 
91  inline void setEndBlock(SP::MATH_EndBlock eb) {
92  mEndBlock=eb;
93  }
94 
97  inline tBoolean isClosed() const {
98  return (mEndBlock.get()!=null);
99  }
108  virtual int evaluate(const tFlag& action,MATH_Environment& env,MATH_Variable& var) const {
109  SPC::MATH_ChildExpression arg=getArgument(0);
110  if (arg!=null) {
111  return arg->evaluate(action,env,var);
112  }
113  return 0;
114  }
115 
116 
140  MATH_Environment& symbols,tString& expr);
141 
142 
146  MATH_ChildExpression* remove();
147 
148 };
149 
150 #endif
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
virtual const char & getBlockString() const
get the block expression character
Definition: MATH_Block.h:64
static SP::MATH_BeginBlock New()
create a node expression
Definition: MATH_BeginBlock.h:53
This class is the base class of a math expression.
Definition: MATH_Expression.h:24
SPC::MATH_ChildExpression getArgument(const int &i) const
get argument at index i for reading
Definition: MATH_ParentExpression.h:124
This class decribes an operator with a name.
Definition: MATH_Operator.h:15
virtual int evaluate(const tFlag &action, MATH_Environment &env, MATH_Variable &var) const
void evaluate the expression
Definition: MATH_BeginBlock.h:108
#define tBoolean
Definition: types.h:35
#define null
Definition: types.h:13
virtual SP::MATH_NodeExpression newInstance() const
create a node expression
Definition: MATH_BeginBlock.h:61
This class decribes a block.
Definition: MATH_Block.h:18
virtual MATH_ChildExpression * insertInTree(MATH_Expression *treeNode, MATH_Environment &symbols, tString &expr)
insert the node This in tree & erase the This corresponding character in expr
Definition: MATH_BeginBlock.cpp:31
This class is a children of a parent expression.
Definition: MATH_ChildExpression.h:23
MATH_BeginBlock(void)
create
Definition: MATH_BeginBlock.cpp:8
virtual tBoolean isCompatible(const MATH_Block &eb) const
test if the begin block This is compatible with the end block
Definition: MATH_BeginBlock.h:79
#define tString
Definition: types.h:36
DEFINE_SPTR(MATH_EndBlock)
Definition: MATH_EndBlock.h:17
tBoolean isClosed() const
return true if the begin block is closed
Definition: MATH_BeginBlock.h:97
This class decribes an environment class.
Definition: MATH_Environment.h:14
void setEndBlock(SP::MATH_EndBlock eb)
set the end block
Definition: MATH_BeginBlock.h:91
virtual ~MATH_BeginBlock(void)
destroy
Definition: MATH_BeginBlock.cpp:13
This class decribes a begin block.
Definition: MATH_BeginBlock.h:21
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14