Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CExpression.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Sun Aug 15 01:53:13 2010 UTC (13 years, 9 months ago) by okadu
File MIME type: text/x-chdr
File size: 3006 byte(s)


1 #ifndef CEXPRESSION_H_INCLUDED
2 #define CEXPRESSION_H_INCLUDED
3
4 class CModelSwitch;
5 class CModelPlugin;
6
7 /*
8 * 数式クラス
9 */
10 class CExpression{
11 public:
12 virtual ~CExpression(){}
13 virtual CExpression *Duplicate() = 0;
14 virtual int CalcInt() = 0;
15 };
16
17 ////////////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////////
19
20 /*
21 * 変数参照クラス
22 */
23 class CVariableReference: public CExpression{
24 private:
25 CModelSwitch *m_Link; // スイッチ
26 public:
27 CVariableReference(CModelSwitch *sw){ m_Link = sw; }
28 CExpression *Duplicate(){ return new CVariableReference(*this); }
29 int CalcInt();
30 };
31
32 /*
33 * 定数クラス
34 */
35 class CConstInteger: public CExpression{
36 private:
37 int m_Constant; // 値
38 public:
39 CConstInteger(int cons){ m_Constant = cons; }
40 CExpression *Duplicate(){ return new CConstInteger(*this); }
41 int CalcInt();
42 };
43
44 ////////////////////////////////////////////////////////////////////////////////
45 ////////////////////////////////////////////////////////////////////////////////
46
47 /*
48 * 単項演算子
49 */
50 class CMonomialOperator: public CExpression{
51 protected:
52 CExpression *m_Child; // 左辺
53 public:
54 CMonomialOperator(){ m_Child = NULL; }
55 CMonomialOperator(CExpression *child){ m_Child = child; }
56 virtual ~CMonomialOperator();
57 void CopyOperand(const CMonomialOperator *);
58 virtual CExpression *Duplicate() = 0;
59 virtual int CalcInt() = 0;
60 };
61
62 ////////////////////////////////////////////////////////////////////////////////
63 ////////////////////////////////////////////////////////////////////////////////
64
65 /*
66 * 二項演算子
67 */
68 class CBinomialOperator: public CExpression{
69 protected:
70 CExpression *m_Left; // 左辺
71 CExpression *m_Right; // 右辺
72 public:
73 CBinomialOperator(){ m_Left = m_Right = NULL; }
74 CBinomialOperator(CExpression *left, CExpression *right){
75 m_Left = left; m_Right = right;
76 }
77 virtual ~CBinomialOperator();
78 void CopyOperand(const CBinomialOperator *);
79 virtual CExpression *Duplicate() = 0;
80 virtual int CalcInt() = 0;
81 };
82
83 ////////////////////////////////////////////////////////////////////////////////
84 ////////////////////////////////////////////////////////////////////////////////
85
86 /*
87 * 三項演算子
88 */
89 class CTrinomialOperator: public CExpression{
90 protected:
91 CExpression *m_Condition; // 条件式
92 CExpression *m_TrueExpr; // 真式
93 CExpression *m_FalseExpr; // 偽式
94 public:
95 CTrinomialOperator(){ m_Condition = m_TrueExpr = m_FalseExpr = NULL; }
96 CTrinomialOperator(CExpression *cond, CExpression *te, CExpression *fe){
97 m_Condition = cond; m_TrueExpr = te; m_FalseExpr = fe;
98 }
99 virtual ~CTrinomialOperator();
100 void CopyOperand(const CTrinomialOperator *);
101 virtual CExpression *Duplicate(){ return new CTrinomialOperator(*this); }
102 virtual int CalcInt();
103 };
104
105 // 関数宣言
106 char *Expression(char *, CExpression **);
107
108 // 外部グローバル
109 extern CModelPlugin *g_SwitchOwner;
110
111 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26