diff --git a/ChangeLog b/ChangeLog index 0625f0ca..9c50aa4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-06-10 Tatsuhiro Tsujikawa + + Made protected member variable private. Added accessor funcs. + * src/BtCheckIntegrityEntry.cc + * src/BtFileAllocationEntry.cc + * src/CheckIntegrityEntry.cc + * src/CheckIntegrityEntry.h + * src/ChecksumCheckIntegrityEntry.cc + * src/FileAllocationEntry.cc + * src/PieceHashCheckIntegrityEntry.cc + * src/RequestGroupEntry.h + * src/StreamCheckIntegrityEntry.cc + * src/StreamFileAllocationEntry.cc + 2010-06-09 Tatsuhiro Tsujikawa Made protected member variable private. Added accessor funcs. diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc index 701224c9..9766f6a3 100644 --- a/src/BtCheckIntegrityEntry.cc +++ b/src/BtCheckIntegrityEntry.cc @@ -55,7 +55,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete (std::vector& commands, DownloadEngine* e) { const SharedHandle& diskAdaptor = - _requestGroup->getPieceStorage()->getDiskAdaptor(); + getRequestGroup()->getPieceStorage()->getDiskAdaptor(); if(diskAdaptor->isReadOnlyEnabled()) { // Now reopen DiskAdaptor with read only disabled. diskAdaptor->closeFile(); @@ -63,7 +63,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete diskAdaptor->openFile(); } SharedHandle entry - (new BtFileAllocationEntry(_requestGroup)); + (new BtFileAllocationEntry(getRequestGroup())); proceedFileAllocation(commands, entry, e); } @@ -74,9 +74,9 @@ void BtCheckIntegrityEntry::onDownloadFinished // are valid, then aira2 goes to seeding mode. Sometimes it is better // to exit rather than doing seeding. So, it would be good to toggle this // behavior. - if(_requestGroup->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) { + if(getRequestGroup()->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) { SharedHandle entry - (new BtFileAllocationEntry(_requestGroup)); + (new BtFileAllocationEntry(getRequestGroup())); proceedFileAllocation(commands, entry, e); } } diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc index c6b2057d..834a318e 100644 --- a/src/BtFileAllocationEntry.cc +++ b/src/BtFileAllocationEntry.cc @@ -55,13 +55,15 @@ BtFileAllocationEntry::~BtFileAllocationEntry() {} void BtFileAllocationEntry::prepareForNextAction (std::vector& commands, DownloadEngine* e) { - BtSetup().setup(commands, _requestGroup, e, _requestGroup->getOption().get()); - if(!_requestGroup->downloadFinished()) { - _requestGroup->getDownloadContext()->resetDownloadStartTime(); + BtSetup().setup(commands, getRequestGroup(), e, + getRequestGroup()->getOption().get()); + if(!getRequestGroup()->downloadFinished()) { + getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); const std::vector >& fileEntries = - _requestGroup->getDownloadContext()->getFileEntries(); - if(isUriSuppliedForRequsetFileEntry(fileEntries.begin(), fileEntries.end())) { - _requestGroup->createNextCommandWithAdj(commands, e, 0); + getRequestGroup()->getDownloadContext()->getFileEntries(); + if(isUriSuppliedForRequsetFileEntry + (fileEntries.begin(), fileEntries.end())) { + getRequestGroup()->createNextCommandWithAdj(commands, e, 0); } } } diff --git a/src/CheckIntegrityEntry.cc b/src/CheckIntegrityEntry.cc index 173822e2..643cb540 100644 --- a/src/CheckIntegrityEntry.cc +++ b/src/CheckIntegrityEntry.cc @@ -84,7 +84,7 @@ bool CheckIntegrityEntry::finished() void CheckIntegrityEntry::cutTrailingGarbage() { - _requestGroup->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage(); + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage(); } void CheckIntegrityEntry::proceedFileAllocation @@ -92,16 +92,21 @@ void CheckIntegrityEntry::proceedFileAllocation const SharedHandle& entry, DownloadEngine* e) { - if(_requestGroup->needsFileAllocation()) { + if(getRequestGroup()->needsFileAllocation()) { e->getFileAllocationMan()->pushEntry(entry); } else { entry->prepareForNextAction(commands, e); } // Disable directIO when fallocation() is going to be used. - if(_requestGroup->getOption()->get(PREF_FILE_ALLOCATION) == V_FALLOC) { + if(getRequestGroup()->getOption()->get(PREF_FILE_ALLOCATION) == V_FALLOC) { entry->disableDirectIO(); } } +void CheckIntegrityEntry::setValidator +(const SharedHandle& validator) +{ + _validator = validator; +} } // namespace aria2 diff --git a/src/CheckIntegrityEntry.h b/src/CheckIntegrityEntry.h index 6c7110cb..ea322412 100644 --- a/src/CheckIntegrityEntry.h +++ b/src/CheckIntegrityEntry.h @@ -48,8 +48,10 @@ class FileAllocationEntry; class CheckIntegrityEntry : public RequestGroupEntry, public ProgressAwareEntry { -protected: +private: SharedHandle _validator; +protected: + void setValidator(const SharedHandle& validator); void proceedFileAllocation(std::vector& commands, const SharedHandle& entry, diff --git a/src/ChecksumCheckIntegrityEntry.cc b/src/ChecksumCheckIntegrityEntry.cc index ad3d67f5..df255511 100644 --- a/src/ChecksumCheckIntegrityEntry.cc +++ b/src/ChecksumCheckIntegrityEntry.cc @@ -52,16 +52,17 @@ ChecksumCheckIntegrityEntry::~ChecksumCheckIntegrityEntry() {} bool ChecksumCheckIntegrityEntry::isValidationReady() { - return !_requestGroup->getDownloadContext()->getChecksum().empty() && - !_requestGroup->getDownloadContext()->getChecksumHashAlgo().empty(); + return !getRequestGroup()->getDownloadContext()->getChecksum().empty() && + !getRequestGroup()->getDownloadContext()->getChecksumHashAlgo().empty(); } void ChecksumCheckIntegrityEntry::initValidator() { - _validator.reset(new IteratableChecksumValidator - (_requestGroup->getDownloadContext(), - _requestGroup->getPieceStorage())); - _validator->init(); + SharedHandle validator + (new IteratableChecksumValidator(getRequestGroup()->getDownloadContext(), + getRequestGroup()->getPieceStorage())); + validator->init(); + setValidator(validator); } void diff --git a/src/FileAllocationEntry.cc b/src/FileAllocationEntry.cc index e6829602..dc9cee6c 100644 --- a/src/FileAllocationEntry.cc +++ b/src/FileAllocationEntry.cc @@ -49,12 +49,12 @@ FileAllocationEntry::FileAllocationEntry(RequestGroup* requestGroup, Command* ne RequestGroupEntry(requestGroup, nextCommand), _fileAllocationIterator(requestGroup->getPieceStorage()->getDiskAdaptor()->fileAllocationIterator()) { - _requestGroup->getPieceStorage()->getDiskAdaptor()->enableDirectIO(); + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableDirectIO(); } FileAllocationEntry:: ~FileAllocationEntry() { - _requestGroup->getPieceStorage()->getDiskAdaptor()->disableDirectIO(); + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->disableDirectIO(); } off_t FileAllocationEntry::getCurrentLength() @@ -79,7 +79,7 @@ void FileAllocationEntry::allocateChunk() void FileAllocationEntry::disableDirectIO() { - _requestGroup->getPieceStorage()->getDiskAdaptor()->disableDirectIO(); + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->disableDirectIO(); } } // namespace aria2 diff --git a/src/PieceHashCheckIntegrityEntry.cc b/src/PieceHashCheckIntegrityEntry.cc index 6b784eb8..aea5d80c 100644 --- a/src/PieceHashCheckIntegrityEntry.cc +++ b/src/PieceHashCheckIntegrityEntry.cc @@ -40,8 +40,9 @@ namespace aria2 { -PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry(RequestGroup* requestGroup, - Command* nextCommand): +PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry +(RequestGroup* requestGroup, + Command* nextCommand): CheckIntegrityEntry(requestGroup, nextCommand) {} PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {} @@ -49,7 +50,7 @@ PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {} bool PieceHashCheckIntegrityEntry::isValidationReady() { const SharedHandle& dctx = - _requestGroup->getDownloadContext(); + getRequestGroup()->getDownloadContext(); return !dctx->getPieceHashAlgo().empty() && dctx->getPieceHashes().size() > 0 && dctx->getPieceHashes().size() == dctx->getNumPieces(); @@ -59,10 +60,11 @@ void PieceHashCheckIntegrityEntry::initValidator() { #ifdef ENABLE_MESSAGE_DIGEST IteratableChunkChecksumValidatorHandle validator - (new IteratableChunkChecksumValidator(_requestGroup->getDownloadContext(), - _requestGroup->getPieceStorage())); + (new IteratableChunkChecksumValidator + (getRequestGroup()->getDownloadContext(), + getRequestGroup()->getPieceStorage())); validator->init(); - _validator = validator; + setValidator(validator); #endif // ENABLE_MESSAGE_DIGEST } diff --git a/src/RequestGroupEntry.h b/src/RequestGroupEntry.h index a7c56146..0275c5a4 100644 --- a/src/RequestGroupEntry.h +++ b/src/RequestGroupEntry.h @@ -44,7 +44,7 @@ class RequestGroup; class Command; class RequestGroupEntry { -protected: +private: RequestGroup* _requestGroup; Command* _nextCommand; public: diff --git a/src/StreamCheckIntegrityEntry.cc b/src/StreamCheckIntegrityEntry.cc index 1c88c212..e3a02bce 100644 --- a/src/StreamCheckIntegrityEntry.cc +++ b/src/StreamCheckIntegrityEntry.cc @@ -53,7 +53,7 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete (std::vector& commands, DownloadEngine* e) { SharedHandle entry - (new StreamFileAllocationEntry(_requestGroup, popNextCommand())); + (new StreamFileAllocationEntry(getRequestGroup(), popNextCommand())); proceedFileAllocation(commands, entry, e); } diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index c0282f8a..e771e758 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -59,16 +59,16 @@ void StreamFileAllocationEntry::prepareForNextAction (std::vector& commands, DownloadEngine* e) { - _requestGroup->getDownloadContext()->resetDownloadStartTime(); - if(_nextCommand) { + getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); + if(getNextCommand()) { // give _nextCommand a chance to execute in the next execution loop. - _nextCommand->setStatus(Command::STATUS_ONESHOT_REALTIME); + getNextCommand()->setStatus(Command::STATUS_ONESHOT_REALTIME); e->setNoWait(true); commands.push_back(popNextCommand()); // try remaining uris - _requestGroup->createNextCommandWithAdj(commands, e, -1); + getRequestGroup()->createNextCommandWithAdj(commands, e, -1); } else { - _requestGroup->createNextCommandWithAdj(commands, e, 0); + getRequestGroup()->createNextCommandWithAdj(commands, e, 0); } }