00001
00002
00003
00004
00005 #ifndef LOOPCOMMAND_H
00006 #define LOOPCOMMAND_H
00007
00008 #include "gui/Command.h"
00009 namespace gui {
00010
00011 class LoopCommand : public Command {
00012
00013
00014
00015 public:
00016 LoopCommand(Command* command, long count);
00017
00018
00019 ~LoopCommand();
00020
00021
00022 void setCount(long count){m_count = count;}
00023
00024
00025
00026 int getCount()const{return m_count;}
00027
00028
00029
00030 int getCurrent()const{return m_current;}
00031
00032
00033 void setCommand(Command* cmd){m_command =cmd;}
00034
00035
00036 void execute();
00037
00038
00039 void pause();
00040
00041
00042 void abort();
00043
00044
00045 void resume();
00046
00047
00048 void stop();
00049
00050
00051 enum Status {STOPPED, RUNNING, PAUSED, ABORTED};
00052
00053 Status status()const;
00054
00055
00056 Command* abortCommand();
00057
00058
00059 Command* pauseCommand();
00060
00061
00062 Command* resumeCommand();
00063
00064
00065 private:
00066 class LCommand : public Command {
00067
00068 friend class LoopCommand;
00069 typedef void (LoopCommand::* Action)();
00070
00071 LCommand(LoopCommand* r, Action a):
00072 _receiver(r), _action(a) {}
00073
00074 virtual void execute(){ (_receiver->*_action)();}
00075
00076 LoopCommand* _receiver;
00077 Action _action;
00078 };
00079
00080 Command* m_command;
00081 unsigned long m_count;
00082 unsigned long m_current;
00083 Status m_status;
00084 };
00085 }
00086 #endif