X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Ffsm%2Fscd_cont_fsm.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Ffsm%2Fscd_cont_fsm.h;h=f5d2eb4d887fd935ae48cf83603f25f1d78afa9b;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/fsm/scd_cont_fsm.h b/dol/src/dol/visitor/hdsd/scd/fsm/scd_cont_fsm.h new file mode 100644 index 0000000..f5d2eb4 --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/fsm/scd_cont_fsm.h @@ -0,0 +1,54 @@ +#ifndef SCD_CONT_FSM_H +#define SCD_CONT_FSM_H + +#include + +/* forward declaration */ +class scd_cont_state; + + +/** + * FSM base class. Holds the current and the history state and allows + * state transitions. Transitions are logged in debug loglevel. + */ +class scd_cont_fsm +{ + +public: + /** + * Constructor. + * \param name the name of the state machine + */ + scd_cont_fsm(const std::string& name): _name(name) {} + + virtual ~scd_cont_fsm() {} + + /** + * Sets a new state. This is a state transition. + */ + void set_state(scd_cont_state& state); + + /** + * Saves the current state as the history state. This is not a state + * transition. + */ + void save_state(); + + /** + * Saves a specified state as the history state. This is not a state + * transition. + */ + void save_state(scd_cont_state& state); + + /** + * Restores the saved history state. This is a state transition. + */ + void load_state(); + +protected: + scd_cont_state* _state; + scd_cont_state* _hist_state; + std::string _name; +}; + +#endif