- added FsmEval
git-svn-id: http://moon:8086/svn/software/trunk/projects/FsmEval@130 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* File: AStateMachine.hpp
|
||||
* Author: jens
|
||||
*
|
||||
* Created on 21. Januar 2015, 05:20
|
||||
*/
|
||||
|
||||
#ifndef ASTATEMACHINE_HPP
|
||||
#define ASTATEMACHINE_HPP
|
||||
|
||||
#include "IStateMachine.hpp"
|
||||
#include "AState.hpp"
|
||||
|
||||
class AStateMachine : public IStateMachine
|
||||
{
|
||||
public:
|
||||
|
||||
AStateMachine()
|
||||
: m_stateCurr(NUM_STATES)
|
||||
, m_stateNext(INIT)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AStateMachine()
|
||||
{
|
||||
}
|
||||
|
||||
void add(StateId stateId, AState *pState)
|
||||
{
|
||||
pState->registerStateMachine(this);
|
||||
m_states[stateId] = pState;
|
||||
}
|
||||
|
||||
void setState(StateId stateId)
|
||||
{
|
||||
m_stateNext = stateId;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* ASTATEMACHINE_HPP */
|
||||
|
||||
Reference in New Issue
Block a user