dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hdsd / scd / fsm / scd_cont_fsm.h
1 #ifndef SCD_CONT_FSM_H
2 #define SCD_CONT_FSM_H
3
4 #include <string>
5
6 /* forward declaration */
7 class scd_cont_state;
8
9
10 /**
11  * FSM base class. Holds the current and the history state and allows
12  * state transitions. Transitions are logged in debug loglevel.
13  */
14 class scd_cont_fsm
15 {
16
17 public:
18     /**
19      * Constructor.
20      * \param name the name of the state machine
21      */
22     scd_cont_fsm(const std::string& name): _name(name) {}
23
24     virtual ~scd_cont_fsm() {}
25
26     /**
27      * Sets a new state. This is a state transition.
28      */
29     void set_state(scd_cont_state& state);
30
31     /**
32      * Saves the current state as the history state. This is not a state
33      * transition.
34      */
35     void save_state();
36
37     /**
38      * Saves a specified state as the history state. This is not a state
39      * transition.
40      */
41     void save_state(scd_cont_state& state);
42
43     /**
44      * Restores the saved history state. This is a state transition.
45      */
46     void load_state();
47
48 protected:
49     scd_cont_state* _state;
50     scd_cont_state* _hist_state;
51     std::string _name;
52 };
53
54 #endif