xref: /haiku/src/apps/icon-o-matic/generic/command/CommandStack.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 
9 #ifndef COMMAND_STACK_H
10 #define COMMAND_STACK_H
11 
12 #include <stack>
13 
14 #include <Locker.h>
15 
16 #include "Observable.h"
17 
18 class BString;
19 class Command;
20 
21 class CommandStack : public BLocker,
22 					 public Observable {
23  public:
24 								CommandStack();
25 	virtual						~CommandStack();
26 
27 			status_t			Perform(Command* command);
28 
29 			status_t			Undo();
30 			status_t			Redo();
31 
32 			bool				GetUndoName(BString& name);
33 			bool				GetRedoName(BString& name);
34 
35 			void				Clear();
36 			void				Save();
37 			bool				IsSaved();
38 
39  private:
40 			status_t			_AddCommand(Command* command);
41 
42 	typedef std::stack<Command*> command_stack;
43 
44 			command_stack			fUndoHistory;
45 			command_stack			fRedoHistory;
46 			Command*				fSavedCommand;
47 };
48 
49 #endif // COMMAND_STACK_H
50