- improved
git-svn-id: http://moon:8086/svn/software/trunk/projects/FsmEval@132 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+9
-13
@@ -15,9 +15,8 @@ class AStateMachine : public IStateMachine
|
||||
{
|
||||
public:
|
||||
|
||||
AStateMachine()
|
||||
: m_stateCurr(NUM_STATES)
|
||||
, m_stateNext(INIT)
|
||||
AStateMachine(StateId stateInit)
|
||||
: m_stateCurr(stateInit)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,20 +32,17 @@ public:
|
||||
|
||||
void setState(StateId stateId)
|
||||
{
|
||||
m_stateNext = stateId;
|
||||
bool isTransition = (m_stateCurr != stateId);
|
||||
|
||||
m_stateCurr = stateId;
|
||||
if (isTransition)
|
||||
{
|
||||
m_states[m_stateCurr]->onTransition();
|
||||
}
|
||||
}
|
||||
|
||||
bool transition()
|
||||
{
|
||||
bool isTransition = (m_stateNext != m_stateCurr);
|
||||
|
||||
m_stateCurr = m_stateNext;
|
||||
|
||||
return isTransition;
|
||||
}
|
||||
protected:
|
||||
StateId m_stateCurr;
|
||||
StateId m_stateNext;
|
||||
AState *m_states[NUM_STATES];
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user