mirror of https://github.com/aria2/aria2
DownloadEngine: Use std::unique_ptr for checkIntegrityMan_, fileAllocationMan_
parent
6b397c8125
commit
697c1008f7
|
@ -45,7 +45,7 @@ namespace aria2 {
|
||||||
|
|
||||||
CheckIntegrityDispatcherCommand::CheckIntegrityDispatcherCommand
|
CheckIntegrityDispatcherCommand::CheckIntegrityDispatcherCommand
|
||||||
(cuid_t cuid,
|
(cuid_t cuid,
|
||||||
const std::shared_ptr<CheckIntegrityMan>& fileAllocMan,
|
CheckIntegrityMan* fileAllocMan,
|
||||||
DownloadEngine* e)
|
DownloadEngine* e)
|
||||||
: SequentialDispatcherCommand<CheckIntegrityEntry>{cuid, fileAllocMan, e}
|
: SequentialDispatcherCommand<CheckIntegrityEntry>{cuid, fileAllocMan, e}
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ class CheckIntegrityDispatcherCommand :
|
||||||
public:
|
public:
|
||||||
CheckIntegrityDispatcherCommand
|
CheckIntegrityDispatcherCommand
|
||||||
(cuid_t cuid,
|
(cuid_t cuid,
|
||||||
const std::shared_ptr<CheckIntegrityMan>& checkMan,
|
CheckIntegrityMan* checkMan,
|
||||||
DownloadEngine* e);
|
DownloadEngine* e);
|
||||||
protected:
|
protected:
|
||||||
virtual std::unique_ptr<Command> createCommand(CheckIntegrityEntry* entry);
|
virtual std::unique_ptr<Command> createCommand(CheckIntegrityEntry* entry);
|
||||||
|
|
|
@ -585,15 +585,15 @@ void DownloadEngine::setRequestGroupMan
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadEngine::setFileAllocationMan
|
void DownloadEngine::setFileAllocationMan
|
||||||
(const std::shared_ptr<FileAllocationMan>& faman)
|
(std::unique_ptr<FileAllocationMan> faman)
|
||||||
{
|
{
|
||||||
fileAllocationMan_ = faman;
|
fileAllocationMan_ = std::move(faman);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadEngine::setCheckIntegrityMan
|
void DownloadEngine::setCheckIntegrityMan
|
||||||
(const std::shared_ptr<CheckIntegrityMan>& ciman)
|
(std::unique_ptr<CheckIntegrityMan> ciman)
|
||||||
{
|
{
|
||||||
checkIntegrityMan_ = ciman;
|
checkIntegrityMan_ = std::move(ciman);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ARES_ADDR_NODE
|
#ifdef HAVE_ARES_ADDR_NODE
|
||||||
|
|
|
@ -169,8 +169,8 @@ private:
|
||||||
|
|
||||||
std::deque<std::unique_ptr<Command>> commands_;
|
std::deque<std::unique_ptr<Command>> commands_;
|
||||||
std::shared_ptr<RequestGroupMan> requestGroupMan_;
|
std::shared_ptr<RequestGroupMan> requestGroupMan_;
|
||||||
std::shared_ptr<FileAllocationMan> fileAllocationMan_;
|
std::unique_ptr<FileAllocationMan> fileAllocationMan_;
|
||||||
std::shared_ptr<CheckIntegrityMan> checkIntegrityMan_;
|
std::unique_ptr<CheckIntegrityMan> checkIntegrityMan_;
|
||||||
Option* option_;
|
Option* option_;
|
||||||
public:
|
public:
|
||||||
DownloadEngine(const std::shared_ptr<EventPoll>& eventPoll);
|
DownloadEngine(const std::shared_ptr<EventPoll>& eventPoll);
|
||||||
|
@ -211,19 +211,19 @@ public:
|
||||||
|
|
||||||
void setRequestGroupMan(const std::shared_ptr<RequestGroupMan>& rgman);
|
void setRequestGroupMan(const std::shared_ptr<RequestGroupMan>& rgman);
|
||||||
|
|
||||||
const std::shared_ptr<FileAllocationMan>& getFileAllocationMan() const
|
const std::unique_ptr<FileAllocationMan>& getFileAllocationMan() const
|
||||||
{
|
{
|
||||||
return fileAllocationMan_;
|
return fileAllocationMan_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFileAllocationMan(const std::shared_ptr<FileAllocationMan>& faman);
|
void setFileAllocationMan(std::unique_ptr<FileAllocationMan> faman);
|
||||||
|
|
||||||
const std::shared_ptr<CheckIntegrityMan>& getCheckIntegrityMan() const
|
const std::unique_ptr<CheckIntegrityMan>& getCheckIntegrityMan() const
|
||||||
{
|
{
|
||||||
return checkIntegrityMan_;
|
return checkIntegrityMan_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCheckIntegrityMan(const std::shared_ptr<CheckIntegrityMan>& ciman);
|
void setCheckIntegrityMan(std::unique_ptr<CheckIntegrityMan> ciman);
|
||||||
|
|
||||||
Option* getOption() const
|
Option* getOption() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,19 +153,19 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
(std::move(requestGroups), MAX_CONCURRENT_DOWNLOADS, op);
|
(std::move(requestGroups), MAX_CONCURRENT_DOWNLOADS, op);
|
||||||
requestGroupMan->initWrDiskCache();
|
requestGroupMan->initWrDiskCache();
|
||||||
e->setRequestGroupMan(requestGroupMan);
|
e->setRequestGroupMan(requestGroupMan);
|
||||||
e->setFileAllocationMan
|
e->setFileAllocationMan(make_unique<FileAllocationMan>());
|
||||||
(std::shared_ptr<FileAllocationMan>(new FileAllocationMan()));
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->setCheckIntegrityMan
|
e->setCheckIntegrityMan(make_unique<CheckIntegrityMan>());
|
||||||
(std::shared_ptr<CheckIntegrityMan>(new CheckIntegrityMan()));
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
|
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
|
||||||
(e->newCUID(), e.get()));
|
(e->newCUID(), e.get()));
|
||||||
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
|
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
|
||||||
(e->newCUID(), e->getFileAllocationMan(), e.get()));
|
(e->newCUID(), e->getFileAllocationMan().get(),
|
||||||
|
e.get()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
|
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
|
||||||
(e->newCUID(), e->getCheckIntegrityMan(), e.get()));
|
(e->newCUID(), e->getCheckIntegrityMan().get(),
|
||||||
|
e.get()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace aria2 {
|
||||||
|
|
||||||
FileAllocationDispatcherCommand::FileAllocationDispatcherCommand
|
FileAllocationDispatcherCommand::FileAllocationDispatcherCommand
|
||||||
(cuid_t cuid,
|
(cuid_t cuid,
|
||||||
const std::shared_ptr<FileAllocationMan>& fileAllocMan,
|
FileAllocationMan* fileAllocMan,
|
||||||
DownloadEngine* e)
|
DownloadEngine* e)
|
||||||
: SequentialDispatcherCommand<FileAllocationEntry>{cuid, fileAllocMan, e}
|
: SequentialDispatcherCommand<FileAllocationEntry>{cuid, fileAllocMan, e}
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -47,7 +47,7 @@ class FileAllocationDispatcherCommand :
|
||||||
public:
|
public:
|
||||||
FileAllocationDispatcherCommand
|
FileAllocationDispatcherCommand
|
||||||
(cuid_t cuid,
|
(cuid_t cuid,
|
||||||
const std::shared_ptr<FileAllocationMan>& fileAllocMan,
|
FileAllocationMan* fileAllocMan,
|
||||||
DownloadEngine* e);
|
DownloadEngine* e);
|
||||||
protected:
|
protected:
|
||||||
virtual std::unique_ptr<Command> createCommand(FileAllocationEntry* entry);
|
virtual std::unique_ptr<Command> createCommand(FileAllocationEntry* entry);
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DownloadEngine;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SequentialDispatcherCommand : public Command {
|
class SequentialDispatcherCommand : public Command {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<SequentialPicker<T> > picker_;
|
SequentialPicker<T>* picker_;
|
||||||
|
|
||||||
DownloadEngine* e_;
|
DownloadEngine* e_;
|
||||||
protected:
|
protected:
|
||||||
|
@ -61,7 +61,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
SequentialDispatcherCommand
|
SequentialDispatcherCommand
|
||||||
(cuid_t cuid,
|
(cuid_t cuid,
|
||||||
const std::shared_ptr<SequentialPicker<T>>& picker,
|
SequentialPicker<T>* picker,
|
||||||
DownloadEngine* e)
|
DownloadEngine* e)
|
||||||
: Command{cuid}, picker_{picker}, e_{e}
|
: Command{cuid}, picker_{picker}, e_{e}
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue