- AState and AStateMachine have template stateId
- AStateMachine has linked list for states - AStateMachine::reset() resets to first added state git-svn-id: http://moon:8086/svn/software/trunk/projects/FsmEval@134 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+15
-3
@@ -10,15 +10,25 @@
|
||||
|
||||
#include "IStateMachine.hpp"
|
||||
|
||||
template <class IdType>
|
||||
class AState
|
||||
{
|
||||
public:
|
||||
AState()
|
||||
: m_pStateMachine(0)
|
||||
AState<IdType> *m_pNext;
|
||||
|
||||
AState(IdType id)
|
||||
: m_pNext(0)
|
||||
, m_pStateMachine(0)
|
||||
, m_id(id)
|
||||
{
|
||||
}
|
||||
virtual ~AState() {}
|
||||
|
||||
IdType id()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void registerStateMachine(IStateMachine *pStateMachine)
|
||||
{
|
||||
m_pStateMachine = pStateMachine;
|
||||
@@ -30,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void setState(IStateMachine::StateId state)
|
||||
void setState(IdType state)
|
||||
{
|
||||
if(m_pStateMachine)
|
||||
{
|
||||
@@ -39,6 +49,8 @@ protected:
|
||||
}
|
||||
private:
|
||||
IStateMachine *m_pStateMachine;
|
||||
IdType m_id;
|
||||
|
||||
};
|
||||
|
||||
#endif /* ASTATE_HPP */
|
||||
|
||||
Reference in New Issue
Block a user