mirror of
https://github.com/aria2/aria2.git
synced 2025-01-24 02:31:29 +00:00
Use std::unique_ptr for IteratableValidator
This commit is contained in:
parent
d3a04d10a7
commit
c9e58779e1
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user