- improved

git-svn-id: http://moon:8086/svn/software/trunk/projects/FsmEval@132 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2015-01-23 18:32:23 +00:00
parent bc2002f175
commit 6c2aa8157f
3 changed files with 37 additions and 33 deletions
+9 -13
View File
@@ -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];
};