Default many of CFsm's special functions and remove virtual specifires
Differential Revision: https://code.wildfiregames.com/D5249 This was SVN commit r28053.
This commit is contained in:
parent
78652aa92c
commit
a4f91e43ae
@ -30,34 +30,6 @@ CFsmEvent::~CFsmEvent()
|
|||||||
m_Param = nullptr;
|
m_Param = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFsm::CFsm()
|
|
||||||
{
|
|
||||||
m_Done = false;
|
|
||||||
m_FirstState = FSM_INVALID_STATE;
|
|
||||||
m_CurrState = FSM_INVALID_STATE;
|
|
||||||
m_NextState = FSM_INVALID_STATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFsm::~CFsm()
|
|
||||||
{
|
|
||||||
Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFsm::Setup()
|
|
||||||
{
|
|
||||||
// Does nothing by default
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFsm::Shutdown()
|
|
||||||
{
|
|
||||||
m_Transitions.clear();
|
|
||||||
|
|
||||||
m_Done = false;
|
|
||||||
m_FirstState = FSM_INVALID_STATE;
|
|
||||||
m_CurrState = FSM_INVALID_STATE;
|
|
||||||
m_NextState = FSM_INVALID_STATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFsm::AddTransition(unsigned int state, unsigned int eventType, unsigned int nextState,
|
void CFsm::AddTransition(unsigned int state, unsigned int eventType, unsigned int nextState,
|
||||||
Action* pAction /* = nullptr */, void* pContext /* = nullptr*/)
|
Action* pAction /* = nullptr */, void* pContext /* = nullptr*/)
|
||||||
{
|
{
|
||||||
@ -108,6 +80,5 @@ bool CFsm::Update(unsigned int eventType, void* pEventParam)
|
|||||||
|
|
||||||
bool CFsm::IsDone() const
|
bool CFsm::IsDone() const
|
||||||
{
|
{
|
||||||
// By default the internal flag m_Done is tested
|
|
||||||
return m_Done;
|
return m_Done;
|
||||||
}
|
}
|
||||||
|
@ -81,23 +81,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
class CFsm
|
class CFsm
|
||||||
{
|
{
|
||||||
NONCOPYABLE(CFsm);
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CFsm();
|
|
||||||
virtual ~CFsm();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the state machine. This method must be overriden so that
|
|
||||||
* connections are constructed for the particular state machine implemented.
|
|
||||||
*/
|
|
||||||
virtual void Setup();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear event, transition lists and reset state machine.
|
|
||||||
*/
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new transistion to the state machine.
|
* Adds a new transistion to the state machine.
|
||||||
*/
|
*/
|
||||||
@ -136,9 +120,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the state machine has finished its work.
|
* Tests whether the state machine has finished its work.
|
||||||
* @note This is state machine specific.
|
|
||||||
*/
|
*/
|
||||||
virtual bool IsDone() const;
|
bool IsDone() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TransitionKey
|
struct TransitionKey
|
||||||
@ -177,10 +160,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool IsFirstTime() const;
|
bool IsFirstTime() const;
|
||||||
|
|
||||||
bool m_Done;
|
bool m_Done{false};
|
||||||
unsigned int m_FirstState;
|
unsigned int m_FirstState{FSM_INVALID_STATE};
|
||||||
unsigned int m_CurrState;
|
unsigned int m_CurrState{FSM_INVALID_STATE};
|
||||||
unsigned int m_NextState;
|
unsigned int m_NextState{FSM_INVALID_STATE};
|
||||||
TransitionMap m_Transitions;
|
TransitionMap m_Transitions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user