source: molecuilder/src/Actions/ActionSequence.cpp@ 425da9

Last change on this file since 425da9 was 425da9, checked in by Tillmann Crueger <crueger@…>, 16 years ago

Added mechanism that allow to store and later execute sequences of Actions.

  • Property mode set to 100644
File size: 1.0 KB
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
11using namespace std;
12
13ActionSequence::ActionSequence()
14{
15 // TODO Auto-generated constructor stub
16
17}
18
19ActionSequence::~ActionSequence()
20{
21 // TODO Auto-generated destructor stub
22}
23
24
25void ActionSequence::addAction(Action* _action){
26 actions.push_back(_action);
27}
28
29Action* ActionSequence::removeLastAction(){
30 Action* theAction;
31 theAction = actions.back();
32 actions.pop_back();
33 return theAction;
34}
35
36void ActionSequence::callAll(){
37 deque<Action*>::iterator it;
38 for(it=actions.begin(); it!=actions.end(); it++)
39 (*it)->call();
40}
41
42void ActionSequence::undoAll(){
43 deque<Action*>::reverse_iterator rit;
44 for(rit=actions.rbegin(); rit!=actions.rend(); rit++)
45 (*rit)->undo();
46}
47
48bool 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.