/* */ #ifndef _D_REQUEST_GROUP_MAN_H_ #define _D_REQUEST_GROUP_MAN_H_ #include "common.h" #include "SharedHandle.h" #include "TransferStat.h" #include #include #include namespace aria2 { class DownloadEngine; class RequestGroup; class Command; class Logger; class DownloadResult; class RequestGroupMan { private: std::deque > _requestGroups; std::deque > _reservedGroups; std::deque > _downloadResults; const Logger* _logger; unsigned int _maxSimultaneousDownloads; int32_t _gidCounter; std::string formatDownloadResult(const std::string& status, const SharedHandle& downloadResult) const; public: RequestGroupMan(const std::deque >& requestGroups, unsigned int maxSimultaneousDownloads = 1); bool downloadFinished(); void save(); void closeFile(); void halt(); void forceHalt(); std::deque getInitialCommands(DownloadEngine* e); void removeStoppedGroup(); void fillRequestGroupFromReserver(DownloadEngine* e); void addRequestGroup(const SharedHandle& group); void addReservedGroup(const std::deque >& groups); void addReservedGroup(const SharedHandle& group); size_t countRequestGroup() const; SharedHandle getRequestGroup(size_t index) const; void showDownloadResults(std::ostream& o) const; bool isSameFileBeingDownloaded(RequestGroup* requestGroup) const; TransferStat calculateStat(); class DownloadStat { private: size_t _completed; size_t _error; size_t _inProgress; size_t _waiting; public: DownloadStat():_completed(0), _error(0), _inProgress(0), _waiting(0) {} void setCompleted(size_t c) { _completed = c; } void setError(size_t c) { _error = c; } void setInProgress(size_t c) { _inProgress = c; } void setWaiting(size_t c) { _waiting = c; } bool allCompleted() const { return _error == 0 && _inProgress == 0 && _waiting == 0; } }; DownloadStat getDownloadStat() const; }; typedef SharedHandle RequestGroupManHandle; } // namespace aria2 #endif // _D_REQUEST_GROUP_MAN_H_