Last change
on this file since 53f5e6 was 32df34, checked in by Tillmann Crueger <crueger@…>, 16 years ago |
Added an action that allows grouping and grouped execution of several actions.
|
-
Property mode
set to
100644
|
File size:
1013 bytes
|
Line | |
---|
1 | /*
|
---|
2 | * ActionSequenze.cpp
|
---|
3 | *
|
---|
4 | * Created on: Dec 17, 2009
|
---|
5 | * Author: crueger
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Actions/ActionSequence.hpp"
|
---|
9 | #include "Actions/Action.hpp"
|
---|
10 |
|
---|
11 | using namespace std;
|
---|
12 |
|
---|
13 | ActionSequence::ActionSequence()
|
---|
14 | {}
|
---|
15 |
|
---|
16 | ActionSequence::~ActionSequence()
|
---|
17 | {}
|
---|
18 |
|
---|
19 |
|
---|
20 | void ActionSequence::addAction(Action* _action){
|
---|
21 | actions.push_back(_action);
|
---|
22 | }
|
---|
23 |
|
---|
24 | Action* ActionSequence::removeLastAction(){
|
---|
25 | if(actions.empty()) {
|
---|
26 | return 0;
|
---|
27 | }
|
---|
28 | else {
|
---|
29 | Action* theAction;
|
---|
30 | theAction = actions.back();
|
---|
31 | actions.pop_back();
|
---|
32 | return theAction;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | void ActionSequence::callAll(){
|
---|
37 | deque<Action*>::iterator it;
|
---|
38 | for(it=actions.begin(); it!=actions.end(); it++)
|
---|
39 | (*it)->call();
|
---|
40 | }
|
---|
41 |
|
---|
42 | void ActionSequence::undoAll(){
|
---|
43 | deque<Action*>::reverse_iterator rit;
|
---|
44 | for(rit=actions.rbegin(); rit!=actions.rend(); rit++)
|
---|
45 | (*rit)->undo();
|
---|
46 | }
|
---|
47 |
|
---|
48 | bool ActionSequence::canUndo(){
|
---|
49 | bool canUndo=true;
|
---|
50 | deque<Action*>::iterator it;
|
---|
51 | for(it=actions.begin(); it!=actions.end(); it++)
|
---|
52 | canUndo &= (*it)->canUndo();
|
---|
53 | return canUndo;
|
---|
54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.