00001 #ifndef _COMMANDSTACK_HEADER 00002 #define _COMMANDSTACK_HEADER 00003 00004 00005 #include "Command.h" 00006 #include <list> 00007 00008 00009 namespace ot 00010 { 00011 00012 00013 // class *CommandStack* 00014 // ******************************************************************************************* 00015 // - stack for commands, implementing the command pattern for undo/redo functionality 00016 00017 class CommandStack : public std::list<Command*> 00018 { 00019 public: 00020 CommandStack(SpeechControlSource &parentSrc_); 00021 00022 bool push(Command *cmd); 00023 bool undo(); 00024 bool redo(); 00025 bool extend(); 00026 bool again(); 00027 Command* getUndoCmd() { return *currentCmd; }; 00028 Command* getRedoCmd() { iterator tmp = currentCmd; return *(--tmp); }; 00029 00030 protected: 00031 void deleteAllAbove(); 00032 00033 iterator currentCmd; // pointing to lastly performed command 00034 SpeechControlSource& parentSrc; 00035 }; 00036 00037 00038 } // namespace ot 00039 00040 00041 #endif
1.4.6