00001 #if !defined(AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_)
00002 #define AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include "FSMObject.h"
00062
00064 namespace FSM {
00065
00066
00067
00068 class CFiniteStateMachine;
00069
00070 class CFSMCondition : public CFSMObject
00071 {
00072 public:
00073 friend class CFSMTransition;
00074
00075
00076 virtual bool CheckCondition(const char* event, void *a, void *b) = 0;
00077
00078 protected:
00079
00080
00081 virtual bool Activate();
00082 virtual bool Deactivate();
00083
00084 CFSMCondition();
00085 virtual ~CFSMCondition();
00086 private:
00087 };
00088
00089 class CFSMConditionTestVariable : public CFSMCondition
00090 {
00091 public:
00092 friend class CFSMTransition;
00093 friend class CFiniteStateMachine;
00094
00095 enum OP {
00096 EQUAL,
00097 NEQUAL,
00098 GREATER,
00099 LESS,
00100 GREATER_EQ,
00101 LESS_EQ
00102 };
00103
00104
00105 static CFSMObject *Create();
00106 virtual void DeleteThis();
00107
00108
00109 void SetCondition(const char* varName, OP testCondition, int testValue);
00110 bool SetExpression(const char* expression);
00111
00112 const char* GetVariable() const;
00113 OP GetCondition() const;
00114 int GetValue() const;
00115
00116
00117 virtual bool SetParameter(const char* paramName, const char* paramValue);
00118 virtual bool CheckCondition(const char* event, void *a, void *b);
00119
00120 protected:
00121
00122
00123 virtual bool SaveParameters(CFSMSaver *out) const;
00124
00125 private:
00126 CFSMConditionTestVariable();
00127 virtual ~CFSMConditionTestVariable();
00128
00129 string variableName;
00130 OP condition;
00131 int value;
00132 };
00133
00134 };
00135
00136 #endif // !defined(AFX_FSMCONDITION_H__A3DB3A96_76D7_4B69_A67C_8F6A8601F9B9__INCLUDED_)