Use std::unique_ptr for IteratableValidator

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-05 22:48:34 +09:00
parent d3a04d10a7
commit c9e58779e1
4 changed files with 22 additions and 20 deletions

View File

@ -45,8 +45,8 @@
namespace aria2 {
CheckIntegrityEntry::CheckIntegrityEntry(RequestGroup* requestGroup,
std::unique_ptr<Command> nextCommand):
RequestGroupEntry(requestGroup, std::move(nextCommand))
std::unique_ptr<Command> nextCommand)
: RequestGroupEntry{requestGroup, std::move(nextCommand)}
{}
CheckIntegrityEntry::~CheckIntegrityEntry() {}
@ -97,9 +97,9 @@ void CheckIntegrityEntry::proceedFileAllocation
}
void CheckIntegrityEntry::setValidator
(const std::shared_ptr<IteratableValidator>& validator)
(std::unique_ptr<IteratableValidator> validator)
{
validator_ = validator;
validator_ = std::move(validator);
}
} // namespace aria2

View File

@ -51,9 +51,9 @@ class FileAllocationEntry;
class CheckIntegrityEntry : public RequestGroupEntry,
public ProgressAwareEntry {
private:
std::shared_ptr<IteratableValidator> validator_;
std::unique_ptr<IteratableValidator> validator_;
protected:
void setValidator(const std::shared_ptr<IteratableValidator>& validator);
void setValidator(std::unique_ptr<IteratableValidator> validator);
void proceedFileAllocation(std::vector<std::unique_ptr<Command>>& commands,
const std::shared_ptr<FileAllocationEntry>& entry,

View File

@ -45,9 +45,10 @@
namespace aria2 {
ChecksumCheckIntegrityEntry::ChecksumCheckIntegrityEntry
(RequestGroup* requestGroup, std::unique_ptr<Command> nextCommand):
CheckIntegrityEntry(requestGroup, std::move(nextCommand)),
redownload_(false) {}
(RequestGroup* requestGroup, std::unique_ptr<Command> nextCommand)
: CheckIntegrityEntry{requestGroup, std::move(nextCommand)},
redownload_{false}
{}
ChecksumCheckIntegrityEntry::~ChecksumCheckIntegrityEntry() {}
@ -60,11 +61,11 @@ bool ChecksumCheckIntegrityEntry::isValidationReady()
void ChecksumCheckIntegrityEntry::initValidator()
{
std::shared_ptr<IteratableChecksumValidator> validator
(new IteratableChecksumValidator(getRequestGroup()->getDownloadContext(),
getRequestGroup()->getPieceStorage()));
auto validator = make_unique<IteratableChecksumValidator>
(getRequestGroup()->getDownloadContext(),
getRequestGroup()->getPieceStorage());
validator->init();
setValidator(validator);
setValidator(std::move(validator));
}
void

View File

@ -37,13 +37,15 @@
#include "IteratableChunkChecksumValidator.h"
#include "DownloadContext.h"
#include "PieceStorage.h"
#include "a2functional.h"
namespace aria2 {
PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry
(RequestGroup* requestGroup,
std::unique_ptr<Command> nextCommand):
CheckIntegrityEntry(requestGroup, std::move(nextCommand)) {}
std::unique_ptr<Command> nextCommand)
: CheckIntegrityEntry{requestGroup, std::move(nextCommand)}
{}
PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {}
@ -57,12 +59,11 @@ bool PieceHashCheckIntegrityEntry::isValidationReady()
void PieceHashCheckIntegrityEntry::initValidator()
{
#ifdef ENABLE_MESSAGE_DIGEST
std::shared_ptr<IteratableChunkChecksumValidator> validator
(new IteratableChunkChecksumValidator
auto validator = make_unique<IteratableChunkChecksumValidator>
(getRequestGroup()->getDownloadContext(),
getRequestGroup()->getPieceStorage()));
getRequestGroup()->getPieceStorage());
validator->init();
setValidator(validator);
setValidator(std::move(validator));
#endif // ENABLE_MESSAGE_DIGEST
}