faedc120ee34afb1bbd269b7dca14a29580c1853
[ardour.git] / libs / ardour / ardour / state_manager.h
1 #ifndef __ardour_state_manager_h__
2 #define __ardour_state_manager_h__
3
4 #include <list>
5 #include <string>
6
7 #include <sigc++/signal.h>
8
9 #include <ardour/ardour.h>
10
11 namespace ARDOUR {
12
13 typedef uint32_t state_id_t;
14
15
16 class StateManager : public sigc::trackable
17 {
18   public:
19         struct State {
20             std::string operation;
21             State (std::string why) : operation (why) {}
22             virtual ~State() {}
23         };
24
25         typedef std::list<State*> StateMap;
26
27         StateManager ();
28         virtual ~StateManager ();
29         
30         virtual void drop_all_states ();
31         virtual void use_state (state_id_t);
32         virtual void save_state (std::string why);
33
34         sigc::signal<void,Change> StateChanged;
35
36         state_id_t _current_state_id;
37
38   protected:
39         StateMap   states;
40
41         virtual Change   restore_state (State&) = 0;
42         virtual State* state_factory (std::string why) const = 0;
43         virtual void   send_state_changed (Change);
44 };
45
46 } // namespace ARDOUR
47
48 #endif /* __ardour_state_manager_h__ */