/* */ #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 { protected: SharedHandle > _picker; DownloadEngine* _e; public: SequentialDispatcherCommand(int32_t cuid, const SharedHandle >& picker, DownloadEngine* e): Command(cuid), _picker(picker), _e(e) {} virtual bool execute() { if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) { return true; } if(_picker->hasNext() && !_picker->isPicked()) { _e->commands.push_back(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_