diff --git a/configure.ac b/configure.ac index 977543b9..5e927486 100644 --- a/configure.ac +++ b/configure.ac @@ -93,6 +93,8 @@ AC_LANG([C++]) # Check pkg-config is available PKG_PROG_PKG_CONFIG([0.20]) +CXXFLAGS="-std=c++11 $CXXFLAGS" + # Check static build is requested if test "x$ARIA2_STATIC" = "xyes"; then case "$host" in diff --git a/src/AbstractAuthResolver.cc b/src/AbstractAuthResolver.cc index 2b273cb9..a9730f3d 100644 --- a/src/AbstractAuthResolver.cc +++ b/src/AbstractAuthResolver.cc @@ -42,13 +42,13 @@ AbstractAuthResolver::AbstractAuthResolver() {} AbstractAuthResolver::~AbstractAuthResolver() {} void AbstractAuthResolver::setUserDefinedAuthConfig -(const SharedHandle& authConfig) +(const std::shared_ptr& authConfig) { userDefinedAuthConfig_ = authConfig; } void AbstractAuthResolver::setDefaultAuthConfig -(const SharedHandle& authConfig) +(const std::shared_ptr& authConfig) { defaultAuthConfig_ = authConfig; } diff --git a/src/AbstractAuthResolver.h b/src/AbstractAuthResolver.h index 93e73b87..4801490f 100644 --- a/src/AbstractAuthResolver.h +++ b/src/AbstractAuthResolver.h @@ -41,24 +41,24 @@ namespace aria2 { class AbstractAuthResolver : public AuthResolver { private: - SharedHandle userDefinedAuthConfig_; + std::shared_ptr userDefinedAuthConfig_; - SharedHandle defaultAuthConfig_; + std::shared_ptr defaultAuthConfig_; public: AbstractAuthResolver(); virtual ~AbstractAuthResolver(); - void setUserDefinedAuthConfig(const SharedHandle& authConfig); + void setUserDefinedAuthConfig(const std::shared_ptr& authConfig); - const SharedHandle& getUserDefinedAuthConfig() const + const std::shared_ptr& getUserDefinedAuthConfig() const { return userDefinedAuthConfig_; } - void setDefaultAuthConfig(const SharedHandle& authConfig); + void setDefaultAuthConfig(const std::shared_ptr& authConfig); - const SharedHandle& getDefaultAuthConfig() const + const std::shared_ptr& getDefaultAuthConfig() const { return defaultAuthConfig_; } diff --git a/src/AbstractBtMessage.cc b/src/AbstractBtMessage.cc index 55177370..f4fef342 100644 --- a/src/AbstractBtMessage.cc +++ b/src/AbstractBtMessage.cc @@ -54,7 +54,7 @@ AbstractBtMessage::AbstractBtMessage(uint8_t id, const char* name) AbstractBtMessage::~AbstractBtMessage() {} -void AbstractBtMessage::setPeer(const SharedHandle& peer) +void AbstractBtMessage::setPeer(const std::shared_ptr& peer) { peer_ = peer; } @@ -67,12 +67,12 @@ void AbstractBtMessage::validate() } void -AbstractBtMessage::setBtMessageValidator(const SharedHandle& validator) { +AbstractBtMessage::setBtMessageValidator(const std::shared_ptr& validator) { validator_ = validator; } void AbstractBtMessage::setPieceStorage -(const SharedHandle& pieceStorage) +(const std::shared_ptr& pieceStorage) { pieceStorage_ = pieceStorage; } diff --git a/src/AbstractBtMessage.h b/src/AbstractBtMessage.h index c34269e7..49a1b2ed 100644 --- a/src/AbstractBtMessage.h +++ b/src/AbstractBtMessage.h @@ -56,9 +56,9 @@ private: const char* name_; - SharedHandle pieceStorage_; + std::shared_ptr pieceStorage_; - SharedHandle peer_; + std::shared_ptr peer_; BtMessageDispatcher* dispatcher_; @@ -68,11 +68,11 @@ private: PeerConnection* peerConnection_; - SharedHandle validator_; + std::shared_ptr validator_; bool metadataGetMode_; protected: - const SharedHandle& getPieceStorage() const + const std::shared_ptr& getPieceStorage() const { return pieceStorage_; } @@ -130,12 +130,12 @@ public: cuid_ = cuid; } - const SharedHandle& getPeer() const + const std::shared_ptr& getPeer() const { return peer_; } - void setPeer(const SharedHandle& peer); + void setPeer(const std::shared_ptr& peer); virtual void doReceivedAction() {} @@ -151,9 +151,9 @@ public: virtual void onChokingEvent(const BtChokingEvent& event) {} - void setBtMessageValidator(const SharedHandle& validator); + void setBtMessageValidator(const std::shared_ptr& validator); - void setPieceStorage(const SharedHandle& pieceStorage); + void setPieceStorage(const std::shared_ptr& pieceStorage); void setBtMessageDispatcher(BtMessageDispatcher* dispatcher); diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 9e253025..bb078495 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -79,12 +79,12 @@ namespace aria2 { AbstractCommand::AbstractCommand (cuid_t cuid, - const SharedHandle& req, - const SharedHandle& fileEntry, + const std::shared_ptr& req, + const std::shared_ptr& fileEntry, RequestGroup* requestGroup, DownloadEngine* e, - const SharedHandle& s, - const SharedHandle& socketRecvBuffer, + const std::shared_ptr& s, + const std::shared_ptr& socketRecvBuffer, bool incNumConnection) : Command(cuid), checkPoint_(global::wallclock()), timeout_(requestGroup->getTimeout()), @@ -125,7 +125,7 @@ AbstractCommand::~AbstractCommand() { } void AbstractCommand::useFasterRequest -(const SharedHandle& fasterRequest) +(const std::shared_ptr& fasterRequest) { A2_LOG_INFO(fmt("CUID#%" PRId64 " - Use faster Request hostname=%s, port=%u", getCuid(), @@ -180,7 +180,7 @@ bool AbstractCommand::execute() { if(req_ && fileEntry_->countPooledRequest() > 0 && requestGroup_->getTotalLength()-requestGroup_->getCompletedLength() < calculateMinSplitSize()*2) { - SharedHandle fasterRequest = fileEntry_->findFasterRequest(req_); + std::shared_ptr fasterRequest = fileEntry_->findFasterRequest(req_); if(fasterRequest) { useFasterRequest(fasterRequest); return true; @@ -197,7 +197,7 @@ bool AbstractCommand::execute() { if(getOption()->getAsBool(PREF_SELECT_LEAST_USED_HOST)) { getDownloadEngine()->getRequestGroupMan()->getUsedHosts(usedHosts); } - SharedHandle fasterRequest = + std::shared_ptr fasterRequest = fileEntry_->findFasterRequest (req_, usedHosts, e_->getRequestGroupMan()->getServerStatMan()); if(fasterRequest) { @@ -230,7 +230,7 @@ bool AbstractCommand::execute() { size_t maxSegments = req_?req_->getMaxPipelinedRequest():1; size_t minSplitSize = calculateMinSplitSize(); while(segments_.size() < maxSegments) { - SharedHandle segment = + std::shared_ptr segment = getSegmentMan()->getSegment(getCuid(), minSplitSize); if(!segment) { break; @@ -276,7 +276,7 @@ bool AbstractCommand::execute() { } else { if(checkPoint_.difference(global::wallclock()) >= timeout_) { // timeout triggers ServerStat error state. - SharedHandle ss = + std::shared_ptr ss = e_->getRequestGroupMan()->getOrCreateServerStat(req_->getHost(), req_->getProtocol()); ss->setError(); @@ -375,7 +375,7 @@ bool AbstractCommand::execute() { void AbstractCommand::tryReserved() { if(getDownloadContext()->getFileEntries().size() == 1) { - const SharedHandle& entry = + const std::shared_ptr& entry = getDownloadContext()->getFirstFileEntry(); // Don't create new command if currently file length is unknown // and there are no URI left. Because file length is unknown, we @@ -490,7 +490,7 @@ void AbstractCommand::disableReadCheckSocket() { } void AbstractCommand::setReadCheckSocket -(const SharedHandle& socket) { +(const std::shared_ptr& socket) { if(!socket->isOpen()) { disableReadCheckSocket(); } else { @@ -509,7 +509,7 @@ void AbstractCommand::setReadCheckSocket } void AbstractCommand::setReadCheckSocketIf -(const SharedHandle& socket, bool pred) +(const std::shared_ptr& socket, bool pred) { if(pred) { setReadCheckSocket(socket); @@ -527,7 +527,7 @@ void AbstractCommand::disableWriteCheckSocket() { } void AbstractCommand::setWriteCheckSocket -(const SharedHandle& socket) { +(const std::shared_ptr& socket) { if(!socket->isOpen()) { disableWriteCheckSocket(); } else { @@ -546,7 +546,7 @@ void AbstractCommand::setWriteCheckSocket } void AbstractCommand::setWriteCheckSocketIf -(const SharedHandle& socket, bool pred) +(const std::shared_ptr& socket, bool pred) { if(pred) { setWriteCheckSocket(socket); @@ -555,7 +555,7 @@ void AbstractCommand::setWriteCheckSocketIf } } -void AbstractCommand::swapSocket(SharedHandle& socket) +void AbstractCommand::swapSocket(std::shared_ptr& socket) { disableReadCheckSocket(); disableWriteCheckSocket(); @@ -634,7 +634,7 @@ namespace { // Returns true if proxy is defined for the given protocol. Otherwise // returns false. bool isProxyRequest -(const std::string& protocol, const SharedHandle