summaryrefslogtreecommitdiff
path: root/src/FileAllocationEntry.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-05 11:37:25 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-05 11:37:25 +0000
commit2722c0591f3eda48a674748b29889d1cf46d7f71 (patch)
tree152ee2c2eef2c65e583227a1d1faf2d618adb2ea /src/FileAllocationEntry.h
parent3dd06aacfbd6c8a1a027532e34dd21c04731b309 (diff)
2007-06-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Make download size shown in MB, KB. * src/ConsoleDownloadEngine.h (sendStatistics) * src/Util.h, srcUtil.cc (abbrevSize): New function.
Diffstat (limited to 'src/FileAllocationEntry.h')
-rw-r--r--src/FileAllocationEntry.h63
1 files changed, 10 insertions, 53 deletions
diff --git a/src/FileAllocationEntry.h b/src/FileAllocationEntry.h
index d8cea83a..1dfe21d9 100644
--- a/src/FileAllocationEntry.h
+++ b/src/FileAllocationEntry.h
@@ -35,76 +35,33 @@
#ifndef _D_FILE_ALLOCATION_ENTRY_H_
#define _D_FILE_ALLOCATION_ENTRY_H_
-#include "common.h"
-#include "Request.h"
-#include "RequestGroup.h"
+#include "RequestGroupEntry.h"
-class DownloadCommand;
-
-class FileAllocationEntry {
+class FileAllocationEntry : public RequestGroupEntry {
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;
- }
+ RequestGroupEntry(cuid, currentRequest, requestGroup),
+ _offset(offset)
+ {}
- RequestGroup* getRequestGroup() const
- {
- return _requestGroup;
- }
+ virtual ~FileAllocationEntry() {}
- void setOffset(int64_t offset)
- {
- _offset = offset;
- }
-
- int64_t getOffset() const
+ virtual int64_t getCurrentLength() const
{
return _offset;
}
- void allocateChunk();
-
- bool allocationFinished() const
+ virtual bool finished() const
{
- return _requestGroup->getSegmentMan()->totalSize <= _offset;
+ return _requestGroup->getTotalLength() <= _offset;
}
- void setNextDownloadCommand(DownloadCommand* command)
- {
- _nextDownloadCommand = command;
- }
-
- DownloadCommand* getNextDownloadCommand() const
- {
- return _nextDownloadCommand;
- }
+ void allocateChunk();
};
typedef SharedHandle<FileAllocationEntry> FileAllocationEntryHandle;