00001 #if !defined(AFX_FSMACTION_H__7C6ABC20_3696_40ED_9DC4_8C06E73BFC85__INCLUDED_)
00002 #define AFX_FSMACTION_H__7C6ABC20_3696_40ED_9DC4_8C06E73BFC85__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
00062
00063
00064
00065 #include "FSMObject.h"
00066
00068 namespace FSM {
00069
00070
00071 class CFiniteStateMachine;
00072
00076 class CFSMAction : public CFSMObject
00077 {
00078 public:
00079 friend class CFSMState;
00080 friend class CFSMTransition;
00081
00082
00083 virtual bool Execute(const char* event, void *a, void *b) =0;
00084
00085 protected:
00086
00087 CFSMAction();
00088 virtual ~CFSMAction();
00089 private:
00090 };
00091
00095 class CFSMActionSetVariable : public CFSMAction
00096 {
00097 public:
00098 friend class CFSMState;
00099 friend class CFSMTransition;
00100 friend class CFiniteStateMachine;
00101
00102
00103 static CFSMObject *Create();
00104 virtual void DeleteThis();
00105
00106
00107 void SetVariable(const char* varName);
00108 void SetValue(int val);
00109
00110 const char* GetVariable() const;
00111 int GetValue() const;
00112
00113
00114 virtual bool Execute(const char* event, void *a, void *b);
00115 virtual bool SetParameter(const char* paramName, const char* paramValue);
00116
00117 protected:
00118
00119
00120 virtual bool SaveParameters(CFSMSaver* out) const;
00121
00122 private:
00123 CFSMActionSetVariable();
00124 virtual ~CFSMActionSetVariable();
00125
00126 string variableName;
00127 int value;
00128 };
00129
00133 class CFSMActionIncrVariable : public CFSMAction
00134 {
00135 public:
00136 friend class CFSMState;
00137 friend class CFSMTransition;
00138 friend class CFiniteStateMachine;
00139
00140
00141 static CFSMObject *Create();
00142 virtual void DeleteThis();
00143
00144
00145 void SetVariable(const char* varName);
00146 void SetIncrement(int val);
00147
00148 const char* GetVariable() const;
00149 int GetIncrement() const;
00150
00151
00152 virtual bool Execute(const char* event, void *a, void *b);
00153 virtual bool SetParameter(const char* paramName, const char* paramValue);
00154
00155 protected:
00156
00157
00158 virtual bool SaveParameters(CFSMSaver* out) const;
00159
00160 private:
00161 CFSMActionIncrVariable();
00162 virtual ~CFSMActionIncrVariable();
00163
00164 string variableName;
00165 int increment;
00166 };
00167
00168 };
00169
00170 #endif // !defined(AFX_FSMACTION_H__7C6ABC20_3696_40ED_9DC4_8C06E73BFC85__INCLUDED_)