Merged with trunk R992.
[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 #include <set>
7
8 #include <sigc++/signal.h>
9
10 #include <ardour/ardour.h>
11
12 namespace ARDOUR {
13
14 typedef uint32_t state_id_t;
15
16 class StateManager : public virtual 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         virtual bool should_save_state () const { return true; }
39
40         static void prohibit_save ();
41         static void allow_save (const char* why, bool dosave);
42
43   protected:
44         static bool _allow_save;
45         static sigc::signal<void,const char*> SaveAllowed;
46
47         StateMap   states;
48
49         virtual Change   restore_state (State&) = 0;
50         virtual State* state_factory (std::string why) const = 0;
51         virtual void   send_state_changed (Change);
52 };
53
54 } // namespace ARDOUR
55
56 #endif /* __ardour_state_manager_h__ */