26 lines
473 B
C
26 lines
473 B
C
|
#ifndef __FSM__
|
||
|
#define __FSM__
|
||
|
|
||
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
// This is a state machine implement in cpp template
|
||
|
template <typename T1,typename T2>
|
||
|
class StateMachine{
|
||
|
public:
|
||
|
StateMachine(){
|
||
|
std::cout<<"call first";
|
||
|
}
|
||
|
virtual void SetStateLink(){
|
||
|
return;
|
||
|
}
|
||
|
virtual int UpdateState(T2){
|
||
|
return -100;
|
||
|
}; //update a state
|
||
|
T1 CurrentState(){
|
||
|
return -100;
|
||
|
}
|
||
|
protected:
|
||
|
T1 mState;
|
||
|
};
|
||
|
|
||
|
#endif
|