summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/state_manager.h
blob: e123b2cb3775adcb72bd0077ebde1fd3cd6bd036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __ardour_state_manager_h__
#define __ardour_state_manager_h__

#include <list>
#include <string>
#include <set>

#include <sigc++/signal.h>

#include <ardour/ardour.h>

namespace ARDOUR {

typedef uint32_t state_id_t;

class StateManager : public virtual sigc::trackable
{
  public:
	struct State {
	    std::string operation;
	    State (std::string why) : operation (why) {}
	    virtual ~State() {}
	};

	typedef std::list<State*> StateMap;

	StateManager ();
	virtual ~StateManager ();
	
	virtual void drop_all_states ();
	virtual void use_state (state_id_t);
	virtual void save_state (std::string why);

	sigc::signal<void,Change> StateChanged;

	state_id_t _current_state_id;

	virtual bool should_save_state () const { return true; }

	static void prohibit_save ();
	static void allow_save (const char* why, bool dosave);

  protected:
	static bool _allow_save;
	static sigc::signal<void,const char*> SaveAllowed;

	StateMap   states;

	virtual Change   restore_state (State&) = 0;
	virtual State* state_factory (std::string why) const = 0;
	virtual void   send_state_changed (Change);
};

} // namespace ARDOUR

#endif /* __ardour_state_manager_h__ */