/* */ #ifndef D_SEQUENTIAL_DISPATCHER_COMMAND_H #define D_SEQUENTIAL_DISPATCHER_COMMAND_H #include "Command.h" #include "SharedHandle.h" #include "SequentialPicker.h" #include "DownloadEngine.h" #include "RequestGroupMan.h" namespace aria2 { class DownloadEngine; template class SequentialDispatcherCommand : public Command { private: SharedHandle > picker_; DownloadEngine* e_; protected: DownloadEngine* getDownloadEngine() const { return e_; } public: SequentialDispatcherCommand(cuid_t cuid, const SharedHandle >& picker, DownloadEngine* e): Command(cuid), picker_(picker), e_(e) { setStatusRealtime(); } virtual bool execute() { if(e_->getRequestGroupMan()->downloadFinished() || e_->isHaltRequested()) { return true; } if(picker_->hasNext() && !picker_->isPicked()) { e_->addCommand(createCommand(picker_->pickNext())); e_->setNoWait(true); } e_->addRoutineCommand(this); return false; } protected: virtual Command* createCommand(const SharedHandle& entry) = 0; }; } // namespace aria2 #endif // D_SEQUENTIAL_DISPATCHER_COMMAND_H