/* */ #ifndef D_TIME_BASED_COMMAND_H #define D_TIME_BASED_COMMAND_H #include "Command.h" #include "TimerA2.h" namespace aria2 { class DownloadEngine; class TimeBasedCommand : public Command { private: DownloadEngine* e_; /** * setting exit_ to true if this command's job has finished and you want to * delete this command. * The exit_ variable is evaluated after preProcess(), process(), * postProcess(), and terminate processing immediately and excute() returns * true. */ bool exit_; time_t interval_; // unit: sec bool routineCommand_; Timer checkPoint_; protected: DownloadEngine* getDownloadEngine() const { return e_; } void enableExit() { exit_ = true; } time_t getInterval() const { return interval_; } public: /** * preProcess() is called each time when excute() is called. */ virtual void preProcess() {}; /** * process() is called only when excute() is called and specified time has * elapsed. */ virtual void process() = 0; /** * postProcess() is called each time when excute() is called. */ virtual void postProcess() {}; public: TimeBasedCommand(cuid_t cuid, DownloadEngine* e, time_t interval, bool routineCommand = false); virtual ~TimeBasedCommand(); virtual bool execute(); }; } // namespace aria2 #endif // D_TIME_BASED_COMMAND_H