/* */ #ifndef _D_FILE_ALLOCATION_ENTRY_H_ #define _D_FILE_ALLOCATION_ENTRY_H_ #include "common.h" #include "Request.h" #include "RequestGroup.h" class DownloadCommand; class FileAllocationEntry { private: int _cuid; RequestHandle _currentRequest; RequestGroup* _requestGroup; int64_t _offset; DownloadCommand* _nextDownloadCommand; public: FileAllocationEntry(int cuid, const RequestHandle& currentRequest, RequestGroup* requestGroup, int64_t offset = 0): _cuid(cuid), _currentRequest(currentRequest), _requestGroup(requestGroup), _offset(offset), _nextDownloadCommand(0) { ++_requestGroup->numConnection; } ~FileAllocationEntry(); int getCUID() const { return _cuid; } RequestHandle getCurrentRequest() const { return _currentRequest; } RequestGroup* getRequestGroup() const { return _requestGroup; } void setOffset(int64_t offset) { _offset = offset; } int64_t getOffset() const { return _offset; } void allocateChunk(); bool allocationFinished() const { return _requestGroup->getSegmentMan()->totalSize <= _offset; } void setNextDownloadCommand(DownloadCommand* command) { _nextDownloadCommand = command; } DownloadCommand* getNextDownloadCommand() const { return _nextDownloadCommand; } }; typedef SharedHandle FileAllocationEntryHandle; typedef deque FileAllocationEntries; #endif // _D_FILE_ALLOCATION_ENTRY_H_