diff --git a/ChangeLog b/ChangeLog index c3ac158c..38461fab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,117 @@ +2009-05-29 Tatsuhiro Tsujikawa + + Implemented getter methods in header files to give them more + chance of optimization. + Return const reference for SharadHandle if possible. + * src/AbstractAuthResolver.cc + * src/AbstractAuthResolver.h + * src/AbstractBtMessage.cc + * src/AbstractBtMessage.h + * src/AbstractSingleDiskAdaptor.cc + * src/AbstractSingleDiskAdaptor.h + * src/AsyncNameResolver.cc + * src/AsyncNameResolver.h + * src/BNode.cc + * src/BNode.h + * src/BitfieldMan.cc + * src/BitfieldMan.h + * src/BtAbortOutstandingRequestEvent.h + * src/BtExtendedMessage.cc + * src/BtExtendedMessage.h + * src/BtSeederStateChoke.cc + * src/BtSeederStateChoke.h + * src/Cookie.cc + * src/Cookie.h + * src/DHTBucket.cc + * src/DHTBucket.h + * src/DHTConnectionImpl.cc + * src/DHTConnectionImpl.h + * src/DHTFindNodeReplyMessage.cc + * src/DHTFindNodeReplyMessage.h + * src/DHTGetPeersReplyMessage.cc + * src/DHTGetPeersReplyMessage.h + * src/DHTInteractionCommand.cc + * src/DHTMessage.cc + * src/DHTMessage.h + * src/DHTMessageDispatcherImpl.cc + * src/DHTMessageEntry.cc + * src/DHTMessageReceiver.cc + * src/DHTMessageReceiver.h + * src/DHTMessageTrackerEntry.cc + * src/DHTMessageTrackerEntry.h + * src/DHTPeerAnnounceEntry.cc + * src/DHTPeerAnnounceEntry.h + * src/DHTPeerLookupTask.cc + * src/DHTPeerLookupTask.h + * src/DHTRoutingTableDeserializer.cc + * src/DHTRoutingTableDeserializer.h + * src/DefaultBtAnnounce.cc + * src/DefaultBtAnnounce.h + * src/DefaultBtMessageDispatcher.cc + * src/DefaultBtMessageDispatcher.h + * src/DefaultBtRequestFactory.cc + * src/DefaultBtRequestFactory.h + * src/DiskAdaptor.cc + * src/DiskAdaptor.h + * src/DownloadContext.cc + * src/DownloadContext.h + * src/DownloadEngine.cc + * src/DownloadEngine.h + * src/EpollEventPoll.cc + * src/EpollEventPoll.h + * src/FtpConnection.cc + * src/FtpConnection.h + * src/HttpConnection.cc + * src/HttpConnection.h + * src/HttpHeader.cc + * src/HttpHeader.h + * src/HttpRequest.cc + * src/HttpRequest.h + * src/HttpResponse.cc + * src/HttpResponse.h + * src/LibsslTLSContext.cc + * src/LibsslTLSContext.h + * src/MSEHandshake.cc + * src/MSEHandshake.h + * src/MetalinkEntry.cc + * src/MetalinkEntry.h + * src/MetalinkParserController.cc + * src/MetalinkParserController.h + * src/MetalinkParserStateMachine.cc + * src/MetalinkParserStateMachine.h + * src/MultiDiskAdaptor.cc + * src/MultiDiskAdaptor.h + * src/NetrcAuthResolver.cc + * src/NetrcAuthResolver.h + * src/Peer.cc + * src/Peer.h + * src/PeerSessionResource.cc + * src/PeerSessionResource.h + * src/Piece.cc + * src/Piece.h + * src/PieceStatMan.cc + * src/PieceStatMan.h + * src/Request.cc + * src/Request.h + * src/RequestGroup.cc + * src/RequestGroup.h + * src/RequestGroupMan.cc + * src/RequestGroupMan.h + * src/RequestSlot.cc + * src/RequestSlot.h + * src/SegmentMan.cc + * src/SegmentMan.h + * src/SelectEventPoll.cc + * src/SelectEventPoll.h + * src/ServerStat.cc + * src/ServerStat.h + * src/Signature.cc + * src/Signature.h + * src/URIResult.cc + * src/URIResult.h + * src/UTPexExtensionMessage.cc + * src/UTPexExtensionMessage.h + 2009-05-28 Tatsuhiro Tsujikawa Fixed compile error without BitTorrent and Metalink support. diff --git a/src/AbstractAuthResolver.cc b/src/AbstractAuthResolver.cc index f44c75fb..4767685d 100644 --- a/src/AbstractAuthResolver.cc +++ b/src/AbstractAuthResolver.cc @@ -46,19 +46,9 @@ void AbstractAuthResolver::setUserDefinedAuthConfig(const AuthConfigHandle& auth _userDefinedAuthConfig = authConfig; } -AuthConfigHandle AbstractAuthResolver::getUserDefinedAuthConfig() const -{ - return _userDefinedAuthConfig; -} - void AbstractAuthResolver::setDefaultAuthConfig(const AuthConfigHandle& authConfig) { _defaultAuthConfig = authConfig; } -AuthConfigHandle AbstractAuthResolver::getDefaultAuthConfig() const -{ - return _defaultAuthConfig; -} - } // namespace aria2 diff --git a/src/AbstractAuthResolver.h b/src/AbstractAuthResolver.h index bdf1370e..0d50197e 100644 --- a/src/AbstractAuthResolver.h +++ b/src/AbstractAuthResolver.h @@ -53,11 +53,18 @@ public: void setUserDefinedAuthConfig(const SharedHandle& authConfig); - SharedHandle getUserDefinedAuthConfig() const; + const SharedHandle& getUserDefinedAuthConfig() const + { + return _userDefinedAuthConfig; + } void setDefaultAuthConfig(const SharedHandle& authConfig); - SharedHandle getDefaultAuthConfig() const; + const SharedHandle& getDefaultAuthConfig() const + { + return _defaultAuthConfig; + } + }; typedef SharedHandle AbstractAuthResolverHandle; diff --git a/src/AbstractBtMessage.cc b/src/AbstractBtMessage.cc index cc43ec48..f2aa432b 100644 --- a/src/AbstractBtMessage.cc +++ b/src/AbstractBtMessage.cc @@ -54,11 +54,6 @@ AbstractBtMessage::AbstractBtMessage(uint8_t id, const std::string& name): AbstractBtMessage::~AbstractBtMessage() {} -SharedHandle AbstractBtMessage::getPeer() const -{ - return peer; -} - void AbstractBtMessage::setPeer(const SharedHandle& peer) { this->peer = peer; @@ -78,21 +73,11 @@ AbstractBtMessage::setBtMessageValidator(const SharedHandle& this->validator = validator; } -SharedHandle AbstractBtMessage::getBtMessageValidator() const -{ - return validator; -} - void AbstractBtMessage::setBtContext(const SharedHandle& btContext) { this->btContext = btContext; } -SharedHandle AbstractBtMessage::getBtContext() const -{ - return btContext; -} - void AbstractBtMessage::setPieceStorage(const SharedHandle& pieceStorage) { this->pieceStorage = pieceStorage; @@ -118,9 +103,4 @@ void AbstractBtMessage::setBtRequestFactory(const WeakHandle& this->requestFactory = factory; } -const std::string& AbstractBtMessage::getName() const -{ - return _name; -} - } // namespace aria2 diff --git a/src/AbstractBtMessage.h b/src/AbstractBtMessage.h index b3d00d6c..16fa4013 100644 --- a/src/AbstractBtMessage.h +++ b/src/AbstractBtMessage.h @@ -36,6 +36,7 @@ #define _D_ABSTRACT_BT_MESSAGE_H_ #include "BtMessage.h" + #include namespace aria2 { @@ -113,7 +114,10 @@ public: this->cuid = cuid; } - SharedHandle getPeer() const; + const SharedHandle& getPeer() const + { + return peer; + } void setPeer(const SharedHandle& peer); @@ -133,11 +137,12 @@ public: void setBtMessageValidator(const SharedHandle& validator); - SharedHandle getBtMessageValidator() const; - void setBtContext(const SharedHandle& btContext); - SharedHandle getBtContext() const; + const SharedHandle& getBtContext() const + { + return btContext; + } void setPieceStorage(const SharedHandle& pieceStorage); @@ -149,7 +154,10 @@ public: void setBtRequestFactory(const WeakHandle& factory); - const std::string& getName() const; + const std::string& getName() const + { + return _name; + } }; typedef SharedHandle AbstractBtMessageHandle; diff --git a/src/AbstractSingleDiskAdaptor.cc b/src/AbstractSingleDiskAdaptor.cc index 698f9e3a..df61c928 100644 --- a/src/AbstractSingleDiskAdaptor.cc +++ b/src/AbstractSingleDiskAdaptor.cc @@ -143,19 +143,9 @@ void AbstractSingleDiskAdaptor::setDiskWriter(const DiskWriterHandle& diskWriter this->diskWriter = diskWriter; } -DiskWriterHandle AbstractSingleDiskAdaptor::getDiskWriter() const -{ - return diskWriter; -} - void AbstractSingleDiskAdaptor::setTotalLength(const uint64_t& totalLength) { this->totalLength = totalLength; } -uint64_t AbstractSingleDiskAdaptor::getTotalLength() const -{ - return totalLength; -} - } // namespace aria2 diff --git a/src/AbstractSingleDiskAdaptor.h b/src/AbstractSingleDiskAdaptor.h index 9ccb2734..559c863b 100644 --- a/src/AbstractSingleDiskAdaptor.h +++ b/src/AbstractSingleDiskAdaptor.h @@ -91,11 +91,17 @@ public: void setDiskWriter(const SharedHandle& diskWriter); - SharedHandle getDiskWriter() const; + const SharedHandle& getDiskWriter() const + { + return diskWriter; + } void setTotalLength(const uint64_t& totalLength); - uint64_t getTotalLength() const; + uint64_t getTotalLength() const + { + return totalLength; + } }; } // namespace aria2 diff --git a/src/AsyncNameResolver.cc b/src/AsyncNameResolver.cc index 0d7e0447..9546b6c8 100644 --- a/src/AsyncNameResolver.cc +++ b/src/AsyncNameResolver.cc @@ -81,21 +81,6 @@ void AsyncNameResolver::resolve(const std::string& name) ares_gethostbyname(channel, name.c_str(), AF_INET, callback, this); } -const std::deque& AsyncNameResolver::getResolvedAddresses() const -{ - return _resolvedAddresses; -} - -const std::string& AsyncNameResolver::getError() const -{ - return error; -} - -AsyncNameResolver::STATUS AsyncNameResolver::getStatus() const -{ - return status; -} - int AsyncNameResolver::getFds(fd_set* rfdsPtr, fd_set* wfdsPtr) const { return ares_fds(channel, rfdsPtr, wfdsPtr); @@ -135,9 +120,4 @@ void AsyncNameResolver::reset() ares_init(&channel); } -const std::string& AsyncNameResolver::getHostname() const -{ - return _hostname; -} - } // namespace aria2 diff --git a/src/AsyncNameResolver.h b/src/AsyncNameResolver.h index acbe178c..37cedf15 100644 --- a/src/AsyncNameResolver.h +++ b/src/AsyncNameResolver.h @@ -79,11 +79,20 @@ public: void resolve(const std::string& name); - const std::deque& getResolvedAddresses() const; + const std::deque& getResolvedAddresses() const + { + return _resolvedAddresses; + } - const std::string& getError() const; + const std::string& getError() const + { + return error; + } - STATUS getStatus() const; + STATUS getStatus() const + { + return status; + } int getFds(fd_set* rfdsPtr, fd_set* wfdsPtr) const; @@ -103,7 +112,11 @@ public: void reset(); - const std::string& getHostname() const; + const std::string& getHostname() const + { + return _hostname; + } + }; } // namespace aria2 diff --git a/src/BNode.cc b/src/BNode.cc index d0489935..6ce9d3b9 100644 --- a/src/BNode.cc +++ b/src/BNode.cc @@ -52,26 +52,6 @@ BNode::~BNode() delete _right; } -SharedHandle BNode::getBucket() const -{ - return _bucket; -} - -BNode* BNode::getLeft() const -{ - return _left; -} - -BNode* BNode::getRight() const -{ - return _right; -} - -BNode* BNode::getUp() const -{ - return _up; -} - void BNode::setLeft(BNode* left) { _left = left; diff --git a/src/BNode.h b/src/BNode.h index c8b692df..27c95d4d 100644 --- a/src/BNode.h +++ b/src/BNode.h @@ -59,19 +59,31 @@ public: ~BNode(); - SharedHandle getBucket() const; + const SharedHandle& getBucket() const + { + return _bucket; + } void setBucket(const SharedHandle& bucket); - BNode* getLeft() const; + BNode* getLeft() const + { + return _left; + } void setLeft(BNode* left); - BNode* getRight() const; + BNode* getRight() const + { + return _right; + } void setRight(BNode* right); - BNode* getUp() const; + BNode* getUp() const + { + return _up; + } void setUp(BNode* up); diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index b733e044..1fbfcb8b 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -142,16 +142,6 @@ BitfieldMan::~BitfieldMan() { delete [] filterBitfield; } -size_t BitfieldMan::getBlockLength() const -{ - return blockLength; -} - -size_t BitfieldMan::getLastBlockLength() const -{ - return totalLength-blockLength*(blocks-1); -} - size_t BitfieldMan::getBlockLength(size_t index) const { if(index == blocks-1) { @@ -452,14 +442,6 @@ size_t BitfieldMan::countMissingBlockNow() const { } } -size_t BitfieldMan::countFilteredBlock() const { - return cachedNumFilteredBlock; -} - -size_t BitfieldMan::countBlock() const { - return blocks; -} - size_t BitfieldMan::countFilteredBlockNow() const { if(filterEnabled) { return bitfield::countSetBit(filterBitfield, blocks); @@ -468,11 +450,6 @@ size_t BitfieldMan::countFilteredBlockNow() const { } } -size_t BitfieldMan::getMaxIndex() const -{ - return blocks-1; -} - bool BitfieldMan::setBitInternal(unsigned char* bitfield, size_t index, bool on) { if(blocks <= index) { return false; } unsigned char mask = 128 >> index%8; @@ -552,16 +529,6 @@ void BitfieldMan::setBitfield(const unsigned char* bitfield, size_t bitfieldLeng updateCache(); } -const unsigned char* BitfieldMan::getBitfield() const -{ - return bitfield; -} - -size_t BitfieldMan::getBitfieldLength() const -{ - return bitfieldLength; -} - void BitfieldMan::clearAllBit() { memset(this->bitfield, 0, this->bitfieldLength); updateCache(); @@ -627,14 +594,6 @@ void BitfieldMan::clearFilter() { updateCache(); } -bool BitfieldMan::isFilterEnabled() const { - return filterEnabled; -} - -uint64_t BitfieldMan::getFilteredTotalLength() const { - return cachedFilteredTotalLength; -} - uint64_t BitfieldMan::getFilteredTotalLengthNow() const { if(!filterBitfield) { return 0; @@ -677,18 +636,10 @@ uint64_t BitfieldMan::getCompletedLength(bool useFilter) const { return completedLength; } -uint64_t BitfieldMan::getCompletedLength() const { - return cachedCompletedLength; -} - uint64_t BitfieldMan::getCompletedLengthNow() const { return getCompletedLength(false); } -uint64_t BitfieldMan::getFilteredCompletedLength() const { - return cachedFilteredComletedLength; -} - uint64_t BitfieldMan::getFilteredCompletedLengthNow() const { return getCompletedLength(true); } @@ -769,9 +720,4 @@ void BitfieldMan::setRandomizer(const SharedHandle& randomizer) this->randomizer = randomizer; } -SharedHandle BitfieldMan::getRandomizer() const -{ - return randomizer; -} - } // namespace aria2 diff --git a/src/BitfieldMan.h b/src/BitfieldMan.h index 8d51df76..3287e2c0 100644 --- a/src/BitfieldMan.h +++ b/src/BitfieldMan.h @@ -111,9 +111,15 @@ public: BitfieldMan& operator=(const BitfieldMan& bitfieldMan); - size_t getBlockLength() const; + size_t getBlockLength() const + { + return blockLength; + } - size_t getLastBlockLength() const; + size_t getLastBlockLength() const + { + return totalLength-blockLength*(blocks-1); + } size_t getBlockLength(size_t index) const; @@ -195,22 +201,38 @@ public: bool isAllBitSet() const; - const unsigned char* getBitfield() const; + const unsigned char* getBitfield() const + { + return bitfield; + } - size_t getBitfieldLength() const; + size_t getBitfieldLength() const + { + return bitfieldLength; + } /** * affected by filter */ - size_t countFilteredBlock() const; + size_t countFilteredBlock() const + { + return cachedNumFilteredBlock; + } + + size_t countBlock() const + { + return blocks; + } - size_t countBlock() const; /** * affected by filter */ size_t countFilteredBlockNow() const; - size_t getMaxIndex() const; + size_t getMaxIndex() const + { + return blocks-1; + } void setBitfield(const unsigned char* bitfield, size_t bitfieldLength); @@ -228,24 +250,38 @@ public: void enableFilter(); void disableFilter(); - bool isFilterEnabled() const; + bool isFilterEnabled() const + { + return filterEnabled; + } + /** * affected by filter */ - uint64_t getFilteredTotalLength() const; + uint64_t getFilteredTotalLength() const + { + return cachedFilteredTotalLength; + } + /** * affected by filter */ uint64_t getFilteredTotalLengthNow() const; - uint64_t getCompletedLength() const; + uint64_t getCompletedLength() const + { + return cachedCompletedLength; + } uint64_t getCompletedLengthNow() const; /** * affected by filter */ - uint64_t getFilteredCompletedLength() const; + uint64_t getFilteredCompletedLength() const + { + return cachedFilteredComletedLength; + } /** * affected by filter */ @@ -253,7 +289,10 @@ public: void setRandomizer(const SharedHandle& randomizer); - SharedHandle getRandomizer() const; + const SharedHandle& getRandomizer() const + { + return randomizer; + } void updateCache(); diff --git a/src/BtAbortOutstandingRequestEvent.h b/src/BtAbortOutstandingRequestEvent.h index a8b6fdb3..257d41f6 100644 --- a/src/BtAbortOutstandingRequestEvent.h +++ b/src/BtAbortOutstandingRequestEvent.h @@ -48,7 +48,7 @@ public: BtAbortOutstandingRequestEvent(const SharedHandle& piece): piece(piece) {} - SharedHandle getPiece() const { return piece; } + const SharedHandle& getPiece() const { return piece; } }; } // namespace aria2 diff --git a/src/BtExtendedMessage.cc b/src/BtExtendedMessage.cc index 0256d9f3..2141cac1 100644 --- a/src/BtExtendedMessage.cc +++ b/src/BtExtendedMessage.cc @@ -116,9 +116,4 @@ void BtExtendedMessage::doReceivedAction() } } -ExtensionMessageHandle BtExtendedMessage::getExtensionMessage() const -{ - return _extensionMessage; -} - } // namespace aria2 diff --git a/src/BtExtendedMessage.h b/src/BtExtendedMessage.h index 63912f92..fdec5f43 100644 --- a/src/BtExtendedMessage.h +++ b/src/BtExtendedMessage.h @@ -78,7 +78,11 @@ public: virtual std::string toString() const; - SharedHandle getExtensionMessage() const; + const SharedHandle& getExtensionMessage() const + { + return _extensionMessage; + } + }; } // namespace aria2 diff --git a/src/BtSeederStateChoke.cc b/src/BtSeederStateChoke.cc index 361d0db4..afda7f34 100644 --- a/src/BtSeederStateChoke.cc +++ b/src/BtSeederStateChoke.cc @@ -77,16 +77,6 @@ BtSeederStateChoke::PeerEntry::operator<(const PeerEntry& rhs) const } } -SharedHandle BtSeederStateChoke::PeerEntry::getPeer() const -{ - return _peer; -} - -unsigned int BtSeederStateChoke::PeerEntry::getUploadSpeed() const -{ - return _uploadSpeed; -} - void BtSeederStateChoke::PeerEntry::disableOptUnchoking() { _peer->optUnchoking(false); @@ -173,9 +163,4 @@ BtSeederStateChoke::executeChoke(const std::deque >& peerSet) } } -const Time& BtSeederStateChoke::getLastRound() const -{ - return _lastRound; -} - } // namespace aria2 diff --git a/src/BtSeederStateChoke.h b/src/BtSeederStateChoke.h index c0ff7f5e..2a777cad 100644 --- a/src/BtSeederStateChoke.h +++ b/src/BtSeederStateChoke.h @@ -69,9 +69,9 @@ private: bool operator<(const PeerEntry& rhs) const; - SharedHandle getPeer() const; + const SharedHandle& getPeer() const { return _peer; } - unsigned int getUploadSpeed() const; + unsigned int getUploadSpeed() const { return _uploadSpeed; } void disableOptUnchoking(); }; @@ -87,7 +87,7 @@ public: void executeChoke(const std::deque >& peerSet); - const Time& getLastRound() const; + const Time& getLastRound() const { return _lastRound; } }; } // namespace aria2 diff --git a/src/Cookie.cc b/src/Cookie.cc index 284d6aa1..635bd2e6 100644 --- a/src/Cookie.cc +++ b/src/Cookie.cc @@ -206,41 +206,6 @@ bool Cookie::isExpired() const return !_expiry == 0 && Time().getTime() >= _expiry; } -const std::string& Cookie::getName() const -{ - return _name; -} - -const std::string& Cookie::getValue() const -{ - return _value; -} - -const std::string& Cookie::getPath() const -{ - return _path; -} - -const std::string& Cookie::getDomain() const -{ - return _domain; -} - -time_t Cookie::getExpiry() const -{ - return _expiry; -} - -bool Cookie::isSecureCookie() const -{ - return _secure; -} - -bool Cookie::isSessionCookie() const -{ - return _expiry == 0; -} - std::string Cookie::toNsCookieFormat() const { std::stringstream ss; diff --git a/src/Cookie.h b/src/Cookie.h index 83150dbd..c355bfba 100644 --- a/src/Cookie.h +++ b/src/Cookie.h @@ -91,19 +91,40 @@ public: bool isExpired() const; - const std::string& getName() const; + const std::string& getName() const + { + return _name; + } - const std::string& getValue() const; + const std::string& getValue() const + { + return _value; + } - const std::string& getPath() const; + const std::string& getPath() const + { + return _path; + } - const std::string& getDomain() const; + const std::string& getDomain() const + { + return _domain; + } - time_t getExpiry() const; + time_t getExpiry() const + { + return _expiry; + } - bool isSecureCookie() const; + bool isSecureCookie() const + { + return _secure; + } - bool isSessionCookie() const; + bool isSessionCookie() const + { + return _expiry == 0; + } std::string toNsCookieFormat() const; }; diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index 3cca03b5..775fba82 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -212,16 +212,6 @@ SharedHandle DHTBucket::split() return rBucket; } -size_t DHTBucket::countNode() const -{ - return _nodes.size(); -} - -const std::deque >& DHTBucket::getNodes() const -{ - return _nodes; -} - void DHTBucket::getGoodNodes(std::deque >& goodNodes) const { goodNodes = _nodes; @@ -283,9 +273,4 @@ SharedHandle DHTBucket::getLRUQuestionableNode() const } } -const std::deque >& DHTBucket::getCachedNodes() const -{ - return _cachedNodes; -} - } // namespace aria2 diff --git a/src/DHTBucket.h b/src/DHTBucket.h index 1c4856e3..57378b80 100644 --- a/src/DHTBucket.h +++ b/src/DHTBucket.h @@ -113,9 +113,15 @@ public: return _min; } - size_t countNode() const; + size_t countNode() const + { + return _nodes.size(); + } - const std::deque >& getNodes() const; + const std::deque >& getNodes() const + { + return _nodes; + } void getGoodNodes(std::deque >& nodes) const; @@ -139,7 +145,11 @@ public: SharedHandle getLRUQuestionableNode() const; - const std::deque >& getCachedNodes() const; + const std::deque >& getCachedNodes() const + { + return _cachedNodes; + } + }; } // namespace aria2 diff --git a/src/DHTConnectionImpl.cc b/src/DHTConnectionImpl.cc index 35ff0f37..e84b7c5d 100644 --- a/src/DHTConnectionImpl.cc +++ b/src/DHTConnectionImpl.cc @@ -107,9 +107,4 @@ ssize_t DHTConnectionImpl::sendMessage(const unsigned char* data, size_t len, return _socket->writeData(data, len, host, port); } -SharedHandle DHTConnectionImpl::getSocket() const -{ - return _socket; -} - } // namespace aria2 diff --git a/src/DHTConnectionImpl.h b/src/DHTConnectionImpl.h index d34c17b7..a46af47a 100644 --- a/src/DHTConnectionImpl.h +++ b/src/DHTConnectionImpl.h @@ -77,7 +77,10 @@ public: virtual ssize_t sendMessage(const unsigned char* data, size_t len, const std::string& host, uint16_t port); - SharedHandle getSocket() const; + const SharedHandle& getSocket() const + { + return _socket; + } }; } // namespace aria2 diff --git a/src/DHTFindNodeReplyMessage.cc b/src/DHTFindNodeReplyMessage.cc index 360b43e3..99831796 100644 --- a/src/DHTFindNodeReplyMessage.cc +++ b/src/DHTFindNodeReplyMessage.cc @@ -96,11 +96,6 @@ std::string DHTFindNodeReplyMessage::getMessageType() const void DHTFindNodeReplyMessage::validate() const {} -const std::deque >& DHTFindNodeReplyMessage::getClosestKNodes() const -{ - return _closestKNodes; -} - void DHTFindNodeReplyMessage::setClosestKNodes(const std::deque >& closestKNodes) { _closestKNodes = closestKNodes; diff --git a/src/DHTFindNodeReplyMessage.h b/src/DHTFindNodeReplyMessage.h index f188c0f3..0749d0e7 100644 --- a/src/DHTFindNodeReplyMessage.h +++ b/src/DHTFindNodeReplyMessage.h @@ -60,7 +60,10 @@ public: virtual void validate() const; - const std::deque >& getClosestKNodes() const; + const std::deque >& getClosestKNodes() const + { + return _closestKNodes; + } void setClosestKNodes(const std::deque >& closestKNodes); diff --git a/src/DHTGetPeersReplyMessage.cc b/src/DHTGetPeersReplyMessage.cc index 0e46cf4a..b914e83c 100644 --- a/src/DHTGetPeersReplyMessage.cc +++ b/src/DHTGetPeersReplyMessage.cc @@ -112,21 +112,11 @@ std::string DHTGetPeersReplyMessage::getMessageType() const void DHTGetPeersReplyMessage::validate() const {} -const std::deque >& DHTGetPeersReplyMessage::getClosestKNodes() const -{ - return _closestKNodes; -} - void DHTGetPeersReplyMessage::setClosestKNodes(const std::deque >& closestKNodes) { _closestKNodes = closestKNodes; } -const std::deque >& DHTGetPeersReplyMessage::getValues() const -{ - return _values; -} - void DHTGetPeersReplyMessage::setValues(const std::deque >& peers) { _values = peers; diff --git a/src/DHTGetPeersReplyMessage.h b/src/DHTGetPeersReplyMessage.h index 62908154..14c78391 100644 --- a/src/DHTGetPeersReplyMessage.h +++ b/src/DHTGetPeersReplyMessage.h @@ -70,9 +70,15 @@ public: virtual void validate() const; - const std::deque >& getClosestKNodes() const; + const std::deque >& getClosestKNodes() const + { + return _closestKNodes; + } - const std::deque >& getValues() const; + const std::deque >& getValues() const + { + return _values; + } void setClosestKNodes(const std::deque >& closestKNodes); diff --git a/src/DHTInteractionCommand.cc b/src/DHTInteractionCommand.cc index 7422d2bf..ec86d7ae 100644 --- a/src/DHTInteractionCommand.cc +++ b/src/DHTInteractionCommand.cc @@ -44,6 +44,7 @@ #include "RequestGroupMan.h" #include "Logger.h" #include "DHTMessageCallback.h" +#include "DHTNode.h" namespace aria2 { diff --git a/src/DHTMessage.cc b/src/DHTMessage.cc index 0ecc2fe2..09dcccba 100644 --- a/src/DHTMessage.cc +++ b/src/DHTMessage.cc @@ -63,14 +63,4 @@ void DHTMessage::generateTransactionID() _transactionID = std::string(&tid[0], &tid[DHT_TRANSACTION_ID_LENGTH]); } -SharedHandle DHTMessage::getLocalNode() const -{ - return _localNode; -} - -SharedHandle DHTMessage::getRemoteNode() const -{ - return _remoteNode; -} - } // namespace aria2 diff --git a/src/DHTMessage.h b/src/DHTMessage.h index ae7bfd28..a009562d 100644 --- a/src/DHTMessage.h +++ b/src/DHTMessage.h @@ -67,9 +67,15 @@ public: return _transactionID; } - SharedHandle getLocalNode() const; + const SharedHandle& getLocalNode() const + { + return _localNode; + } - SharedHandle getRemoteNode() const; + const SharedHandle& getRemoteNode() const + { + return _remoteNode; + } virtual void doReceivedAction() = 0; diff --git a/src/DHTMessageDispatcherImpl.cc b/src/DHTMessageDispatcherImpl.cc index e06456a1..d847595c 100644 --- a/src/DHTMessageDispatcherImpl.cc +++ b/src/DHTMessageDispatcherImpl.cc @@ -42,6 +42,7 @@ #include "Logger.h" #include "DHTConstants.h" #include "StringFormat.h" +#include "DHTNode.h" namespace aria2 { diff --git a/src/DHTMessageEntry.cc b/src/DHTMessageEntry.cc index 5667ed4b..73efbd55 100644 --- a/src/DHTMessageEntry.cc +++ b/src/DHTMessageEntry.cc @@ -35,6 +35,7 @@ #include "DHTMessageEntry.h" #include "DHTMessage.h" #include "DHTMessageCallback.h" +#include "DHTNode.h" namespace aria2 { diff --git a/src/DHTMessageReceiver.cc b/src/DHTMessageReceiver.cc index 3f1e1123..4a7b1180 100644 --- a/src/DHTMessageReceiver.cc +++ b/src/DHTMessageReceiver.cc @@ -143,16 +143,6 @@ DHTMessageReceiver::handleUnknownMessage(const unsigned char* data, return m; } -SharedHandle DHTMessageReceiver::getConnection() const -{ - return _connection; -} - -SharedHandle DHTMessageReceiver::getMessageTracker() const -{ - return _tracker; -} - void DHTMessageReceiver::setConnection(const SharedHandle& connection) { _connection = connection; diff --git a/src/DHTMessageReceiver.h b/src/DHTMessageReceiver.h index 20b2143e..85924c81 100644 --- a/src/DHTMessageReceiver.h +++ b/src/DHTMessageReceiver.h @@ -72,9 +72,15 @@ public: void handleTimeout(); - SharedHandle getConnection() const; + const SharedHandle& getConnection() const + { + return _connection; + } - SharedHandle getMessageTracker() const; + const SharedHandle& getMessageTracker() const + { + return _tracker; + } void setConnection(const SharedHandle& connection); diff --git a/src/DHTMessageTrackerEntry.cc b/src/DHTMessageTrackerEntry.cc index 25204e17..95e5ca25 100644 --- a/src/DHTMessageTrackerEntry.cc +++ b/src/DHTMessageTrackerEntry.cc @@ -75,14 +75,4 @@ bool DHTMessageTrackerEntry::match(const std::string& transactionID, const std:: return false; } -SharedHandle DHTMessageTrackerEntry::getCallback() const -{ - return _callback; -} - -SharedHandle DHTMessageTrackerEntry::getTargetNode() const -{ - return _targetNode; -} - } // namespace aria2 diff --git a/src/DHTMessageTrackerEntry.h b/src/DHTMessageTrackerEntry.h index 25d63ebe..dc46203e 100644 --- a/src/DHTMessageTrackerEntry.h +++ b/src/DHTMessageTrackerEntry.h @@ -72,14 +72,20 @@ public: bool match(const std::string& transactionID, const std::string& ipaddr, uint16_t port) const; - SharedHandle getTargetNode() const; + const SharedHandle& getTargetNode() const + { + return _targetNode; + } const std::string& getMessageType() const { return _messageType; } - SharedHandle getCallback() const; + const SharedHandle& getCallback() const + { + return _callback; + } int64_t getElapsedMillis() const { diff --git a/src/DHTPeerAnnounceEntry.cc b/src/DHTPeerAnnounceEntry.cc index 4a092f4c..e05806ba 100644 --- a/src/DHTPeerAnnounceEntry.cc +++ b/src/DHTPeerAnnounceEntry.cc @@ -76,11 +76,6 @@ size_t DHTPeerAnnounceEntry::countPeerAddrEntry() const return _peerAddrEntries.size(); } -const std::deque& DHTPeerAnnounceEntry::getPeerAddrEntries() const -{ - return _peerAddrEntries; -} - class FindStaleEntry { private: time_t _timeout; diff --git a/src/DHTPeerAnnounceEntry.h b/src/DHTPeerAnnounceEntry.h index f40f1555..d9f66239 100644 --- a/src/DHTPeerAnnounceEntry.h +++ b/src/DHTPeerAnnounceEntry.h @@ -73,7 +73,10 @@ public: size_t countPeerAddrEntry() const; - const std::deque& getPeerAddrEntries() const; + const std::deque& getPeerAddrEntries() const + { + return _peerAddrEntries; + } void removeStalePeerAddrEntry(time_t timeout); diff --git a/src/DHTPeerLookupTask.cc b/src/DHTPeerLookupTask.cc index 392d4a1d..6869498a 100644 --- a/src/DHTPeerLookupTask.cc +++ b/src/DHTPeerLookupTask.cc @@ -102,11 +102,6 @@ void DHTPeerLookupTask::onFinish() } } -const std::deque >& DHTPeerLookupTask::getPeers() const -{ - return _peers; -} - void DHTPeerLookupTask::setBtRuntime(const SharedHandle& btRuntime) { _btRuntime = btRuntime; diff --git a/src/DHTPeerLookupTask.h b/src/DHTPeerLookupTask.h index b01df29c..261e61c3 100644 --- a/src/DHTPeerLookupTask.h +++ b/src/DHTPeerLookupTask.h @@ -68,7 +68,10 @@ public: virtual void onFinish(); - const std::deque >& getPeers() const; + const std::deque >& getPeers() const + { + return _peers; + } void setBtRuntime(const SharedHandle& btRuntime); diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index e2c2ae15..c60172d4 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -56,16 +56,6 @@ DHTRoutingTableDeserializer::DHTRoutingTableDeserializer() {} DHTRoutingTableDeserializer::~DHTRoutingTableDeserializer() {} -SharedHandle DHTRoutingTableDeserializer::getLocalNode() const -{ - return _localNode; -} - -const std::deque >& DHTRoutingTableDeserializer::getNodes() const -{ - return _nodes; -} - static std::istream& readBytes(unsigned char* buf, size_t buflen, std::istream& in, size_t readlen) { diff --git a/src/DHTRoutingTableDeserializer.h b/src/DHTRoutingTableDeserializer.h index 8998dba6..712d8b36 100644 --- a/src/DHTRoutingTableDeserializer.h +++ b/src/DHTRoutingTableDeserializer.h @@ -57,9 +57,15 @@ public: ~DHTRoutingTableDeserializer(); - SharedHandle getLocalNode() const; + const SharedHandle& getLocalNode() const + { + return _localNode; + } - const std::deque >& getNodes() const; + const std::deque >& getNodes() const + { + return _nodes; + } Time getSerializedTime() const { diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 8eaecb20..e68ffb13 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -281,31 +281,16 @@ void DefaultBtAnnounce::setBtRuntime(const BtRuntimeHandle& btRuntime) this->btRuntime = btRuntime; } -BtRuntimeHandle DefaultBtAnnounce::getBtRuntime() const -{ - return btRuntime; -} - void DefaultBtAnnounce::setPieceStorage(const PieceStorageHandle& pieceStorage) { this->pieceStorage = pieceStorage; } -PieceStorageHandle DefaultBtAnnounce::getPieceStorage() const -{ - return pieceStorage; -} - void DefaultBtAnnounce::setPeerStorage(const PeerStorageHandle& peerStorage) { this->peerStorage = peerStorage; } -PeerStorageHandle DefaultBtAnnounce::getPeerStorage() const -{ - return peerStorage; -} - void DefaultBtAnnounce::overrideMinInterval(time_t interval) { minInterval = interval; diff --git a/src/DefaultBtAnnounce.h b/src/DefaultBtAnnounce.h index 053bb23a..a561bbec 100644 --- a/src/DefaultBtAnnounce.h +++ b/src/DefaultBtAnnounce.h @@ -76,15 +76,24 @@ public: void setBtRuntime(const SharedHandle& btRuntime); - SharedHandle getBtRuntime() const; + const SharedHandle& getBtRuntime() const + { + return btRuntime; + } void setPieceStorage(const SharedHandle& pieceStorage); - SharedHandle getPieceStorage() const; + const SharedHandle& getPieceStorage() const + { + return pieceStorage; + } void setPeerStorage(const SharedHandle& peerStorage); - SharedHandle getPeerStorage() const; + const SharedHandle& getPeerStorage() const + { + return peerStorage; + } bool isDefaultAnnounceReady(); diff --git a/src/DefaultBtMessageDispatcher.cc b/src/DefaultBtMessageDispatcher.cc index 236d1c87..1adc3565 100644 --- a/src/DefaultBtMessageDispatcher.cc +++ b/src/DefaultBtMessageDispatcher.cc @@ -407,17 +407,6 @@ size_t DefaultBtMessageDispatcher::countOutstandingUpload() mem_fun_sh(&BtMessage::isUploading)); } -const std::deque >& -DefaultBtMessageDispatcher::getMessageQueue() -{ - return messageQueue; -} - -const std::deque& DefaultBtMessageDispatcher::getRequestSlots() -{ - return requestSlots; -} - void DefaultBtMessageDispatcher::setPeer(const SharedHandle& peer) { this->peer = peer; diff --git a/src/DefaultBtMessageDispatcher.h b/src/DefaultBtMessageDispatcher.h index b9721541..2b3cc2a3 100644 --- a/src/DefaultBtMessageDispatcher.h +++ b/src/DefaultBtMessageDispatcher.h @@ -104,9 +104,15 @@ public: virtual size_t countOutstandingUpload(); - const std::deque >& getMessageQueue(); + const std::deque >& getMessageQueue() const + { + return messageQueue; + } - const RequestSlots& getRequestSlots(); + const RequestSlots& getRequestSlots() const + { + return requestSlots; + } void setPeer(const SharedHandle& peer); diff --git a/src/DefaultBtRequestFactory.cc b/src/DefaultBtRequestFactory.cc index 8330efeb..f14462f1 100644 --- a/src/DefaultBtRequestFactory.cc +++ b/src/DefaultBtRequestFactory.cc @@ -235,11 +235,6 @@ void DefaultBtRequestFactory::getTargetPieceIndexes mem_fun_sh(&Piece::getIndex)); } -std::deque >& DefaultBtRequestFactory::getTargetPieces() -{ - return pieces; -} - void DefaultBtRequestFactory::setBtContext(const SharedHandle& btContext) { this->btContext = btContext; diff --git a/src/DefaultBtRequestFactory.h b/src/DefaultBtRequestFactory.h index 89e1096c..a4000368 100644 --- a/src/DefaultBtRequestFactory.h +++ b/src/DefaultBtRequestFactory.h @@ -86,7 +86,10 @@ public: virtual void getTargetPieceIndexes(std::deque& indexes) const; - std::deque >& getTargetPieces(); + std::deque >& getTargetPieces() + { + return pieces; + } void setCuid(int32_t cuid) { diff --git a/src/DiskAdaptor.cc b/src/DiskAdaptor.cc index 3eee6b58..38e0b3ea 100644 --- a/src/DiskAdaptor.cc +++ b/src/DiskAdaptor.cc @@ -51,9 +51,4 @@ void DiskAdaptor::setFileEntries(const FileEntries& fileEntries) { this->fileEntries = fileEntries; } -const FileEntries& DiskAdaptor::getFileEntries() const -{ - return fileEntries; -} - } // namespace aria2 diff --git a/src/DiskAdaptor.h b/src/DiskAdaptor.h index 0d41c596..6e59826a 100644 --- a/src/DiskAdaptor.h +++ b/src/DiskAdaptor.h @@ -75,7 +75,10 @@ public: void setFileEntries(const std::deque >& fileEntries); - const std::deque >& getFileEntries() const; + const std::deque >& getFileEntries() const + { + return fileEntries; + } virtual SharedHandle fileAllocationIterator() = 0; diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index 1426b001..98811952 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -43,11 +43,6 @@ DownloadContext::DownloadContext(): DownloadContext::~DownloadContext() {} -const std::string& DownloadContext::getDir() const -{ - return _dir; -} - void DownloadContext::setDir(const std::string& dir) { _dir = dir; diff --git a/src/DownloadContext.h b/src/DownloadContext.h index a07a42c7..a73aa236 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -97,7 +97,10 @@ public: */ virtual std::string getActualBasePath() const = 0; - const std::string& getDir() const; + const std::string& getDir() const + { + return _dir; + } void setDir(const std::string& dir); diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index b65a37bb..13767dc4 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -267,11 +267,6 @@ void DownloadEngine::addRoutineCommand(Command* command) _routineCommands.push_back(command); } -SharedHandle DownloadEngine::getCookieStorage() const -{ - return _cookieStorage; -} - void DownloadEngine::poolSocket(const std::string& ipaddr, uint16_t port, const SocketPoolEntry& entry) @@ -428,11 +423,6 @@ DownloadEngine::popPooledSocket return s; } -SharedHandle DownloadEngine::getBtRegistry() const -{ - return _btRegistry; -} - DownloadEngine::SocketPoolEntry::SocketPoolEntry (const SharedHandle& socket, const std::map& options, @@ -448,17 +438,6 @@ bool DownloadEngine::SocketPoolEntry::isTimeout() const return _registeredTime.elapsed(_timeout); } -SharedHandle DownloadEngine::SocketPoolEntry::getSocket() const -{ - return _socket; -} - -const std::map& -DownloadEngine::SocketPoolEntry::getOptions() const -{ - return _options; -} - cuid_t DownloadEngine::newCUID() { return _cuidCounter.newID(); @@ -482,11 +461,6 @@ void DownloadEngine::setAuthConfigFactory _authConfigFactory = factory; } -SharedHandle DownloadEngine::getAuthConfigFactory() const -{ - return _authConfigFactory; -} - void DownloadEngine::setRefreshInterval(time_t interval) { _refreshInterval = interval; diff --git a/src/DownloadEngine.h b/src/DownloadEngine.h index ac16be10..31489e2e 100644 --- a/src/DownloadEngine.h +++ b/src/DownloadEngine.h @@ -97,9 +97,15 @@ private: bool isTimeout() const; - SharedHandle getSocket() const; + const SharedHandle& getSocket() const + { + return _socket; + } - const std::map& getOptions() const; + const std::map& getOptions() const + { + return _options; + } }; // key = IP address:port, value = SocketPoolEntry @@ -226,9 +232,15 @@ public: const std::deque& ipaddrs, uint16_t port); - SharedHandle getCookieStorage() const; + const SharedHandle& getCookieStorage() const + { + return _cookieStorage; + } - SharedHandle getBtRegistry() const; + const SharedHandle& getBtRegistry() const + { + return _btRegistry; + } cuid_t newCUID(); @@ -238,7 +250,10 @@ public: void setAuthConfigFactory(const SharedHandle& factory); - SharedHandle getAuthConfigFactory() const; + const SharedHandle& getAuthConfigFactory() const + { + return _authConfigFactory; + } void setRefreshInterval(time_t interval); }; diff --git a/src/EpollEventPoll.cc b/src/EpollEventPoll.cc index b7681d3c..f8db3705 100644 --- a/src/EpollEventPoll.cc +++ b/src/EpollEventPoll.cc @@ -47,37 +47,11 @@ namespace aria2 { EpollEventPoll::CommandEvent::CommandEvent(Command* command, int events): _command(command), _events(events) {} -bool EpollEventPoll::CommandEvent::operator== -(const CommandEvent& commandEvent) const -{ - return _command == commandEvent._command; -} - -Command* EpollEventPoll::CommandEvent::getCommand() const -{ - return _command; -} - int EpollEventPoll::CommandEvent::getEvents() const { return _events; } -void EpollEventPoll::CommandEvent::addEvents(int events) -{ - _events |= events; -} - -void EpollEventPoll::CommandEvent::removeEvents(int events) -{ - _events &= (~events); -} - -bool EpollEventPoll::CommandEvent::eventsEmpty() const -{ - return _events == 0; -} - void EpollEventPoll::CommandEvent::processEvents(int events) { if((_events&events) || @@ -118,11 +92,6 @@ EpollEventPoll::ADNSEvent::ADNSEvent sock_t socket, int events): _resolver(resolver), _command(command), _socket(socket), _events(events) {} -bool EpollEventPoll::ADNSEvent::operator==(const ADNSEvent& event) const -{ - return _resolver == event._resolver; -} - int EpollEventPoll::ADNSEvent::getEvents() const { return _events; @@ -167,16 +136,6 @@ EpollEventPoll::SocketEntry::SocketEntry(sock_t socket):_socket(socket) memset(&_epEvent, 0, sizeof(struct epoll_event)); } -bool EpollEventPoll::SocketEntry::operator==(const SocketEntry& entry) const -{ - return _socket == entry._socket; -} - -bool EpollEventPoll::SocketEntry::operator<(const SocketEntry& entry) const -{ - return _socket < entry._socket; -} - void EpollEventPoll::SocketEntry::addCommandEvent(const CommandEvent& cev) { std::deque::iterator i = std::find(_commandEvents.begin(), @@ -247,11 +206,6 @@ void EpollEventPoll::SocketEntry::processEvents(int events) } -sock_t EpollEventPoll::SocketEntry::getSocket() const -{ - return _socket; -} - bool EpollEventPoll::SocketEntry::eventEmpty() const { @@ -303,13 +257,6 @@ EpollEventPoll::AsyncNameResolverEntry::AsyncNameResolverEntry {} -bool EpollEventPoll::AsyncNameResolverEntry::operator== -(const AsyncNameResolverEntry& entry) -{ - return _nameResolver == entry._nameResolver && - _command == entry._command; -} - void EpollEventPoll::AsyncNameResolverEntry::addSocketEvents (EpollEventPoll* e) { diff --git a/src/EpollEventPoll.h b/src/EpollEventPoll.h index 58e178b8..5658ba21 100644 --- a/src/EpollEventPoll.h +++ b/src/EpollEventPoll.h @@ -78,15 +78,30 @@ private: public: CommandEvent(Command* command, int events); - Command* getCommand() const; + Command* getCommand() const + { + return _command; + } - void addEvents(int events); - - void removeEvents(int events); - - bool eventsEmpty() const; + void addEvents(int events) + { + _events |= events; + } + + void removeEvents(int events) + { + _events &= (~events); + } + + bool eventsEmpty() const + { + return _events == 0; + } - bool operator==(const CommandEvent& event) const; + bool operator==(const CommandEvent& commandEvent) const + { + return _command == commandEvent._command; + } virtual int getEvents() const; @@ -107,7 +122,10 @@ private: ADNSEvent(const SharedHandle& resolver, Command* command, sock_t socket, int events); - bool operator==(const ADNSEvent& event) const; + bool operator==(const ADNSEvent& event) const + { + return _resolver == event._resolver; + } virtual int getEvents() const; @@ -136,9 +154,15 @@ private: public: SocketEntry(sock_t socket); - bool operator==(const SocketEntry& entry) const; + bool operator==(const SocketEntry& entry) const + { + return _socket == entry._socket; + } - bool operator<(const SocketEntry& entry) const; + bool operator<(const SocketEntry& entry) const + { + return _socket < entry._socket; + } void addCommandEvent(const CommandEvent& cev); @@ -154,8 +178,11 @@ private: struct epoll_event& getEpEvent(); - sock_t getSocket() const; - + sock_t getSocket() const + { + return _socket; + } + bool eventEmpty() const; void processEvents(int events); @@ -177,7 +204,11 @@ private: AsyncNameResolverEntry(const SharedHandle& nameResolver, Command* command); - bool operator==(const AsyncNameResolverEntry& entry); + bool operator==(const AsyncNameResolverEntry& entry) + { + return _nameResolver == entry._nameResolver && + _command == entry._command; + } void addSocketEvents(EpollEventPoll* socketPoll); diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 55c945c0..295ea709 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -446,9 +446,4 @@ void FtpConnection::setBaseWorkingDir(const std::string& baseWorkingDir) _baseWorkingDir = baseWorkingDir; } -const std::string& FtpConnection::getBaseWorkingDir() const -{ - return _baseWorkingDir; -} - } // namespace aria2 diff --git a/src/FtpConnection.h b/src/FtpConnection.h index 604f2447..8845b0b1 100644 --- a/src/FtpConnection.h +++ b/src/FtpConnection.h @@ -114,7 +114,10 @@ public: void setBaseWorkingDir(const std::string& baseWorkingDir); - const std::string& getBaseWorkingDir() const; + const std::string& getBaseWorkingDir() const + { + return _baseWorkingDir; + } }; } // namespace aria2 diff --git a/src/HttpConnection.cc b/src/HttpConnection.cc index f0c7baba..cbbd8697 100644 --- a/src/HttpConnection.cc +++ b/src/HttpConnection.cc @@ -63,16 +63,6 @@ HttpRequestEntry::HttpRequestEntry(const HttpRequestHandle& httpRequest): HttpRequestEntry::~HttpRequestEntry() {} -HttpRequestHandle HttpRequestEntry::getHttpRequest() const -{ - return _httpRequest; -} - -HttpHeaderProcessorHandle HttpRequestEntry::getHttpHeaderProcessor() const -{ - return _proc; -} - HttpConnection::HttpConnection(int32_t cuid, const SocketHandle& socket, const Option* op): diff --git a/src/HttpConnection.h b/src/HttpConnection.h index 87577fea..276d479e 100644 --- a/src/HttpConnection.h +++ b/src/HttpConnection.h @@ -62,9 +62,15 @@ public: ~HttpRequestEntry(); - SharedHandle getHttpRequest() const; + const SharedHandle& getHttpRequest() const + { + return _httpRequest; + } - SharedHandle getHttpHeaderProcessor() const; + const SharedHandle& getHttpHeaderProcessor() const + { + return _proc; + } }; typedef SharedHandle HttpRequestEntryHandle; diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 23ab0b27..4ab6234e 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -173,41 +173,21 @@ RangeHandle HttpHeader::getRange() const return SharedHandle(new Range(startByte, endByte, entityLength)); } -const std::string& HttpHeader::getResponseStatus() const -{ - return _responseStatus; -} - void HttpHeader::setResponseStatus(const std::string& responseStatus) { _responseStatus = responseStatus; } -const std::string& HttpHeader::getVersion() const -{ - return _version; -} - void HttpHeader::setVersion(const std::string& version) { _version = version; } -const std::string& HttpHeader::getMethod() const -{ - return _method; -} - void HttpHeader::setMethod(const std::string& method) { _method = method; } -const std::string& HttpHeader::getRequestPath() const -{ - return _requestPath; -} - void HttpHeader::setRequestPath(const std::string& requestPath) { _requestPath = requestPath; diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 96bb14d5..6611a794 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -77,19 +77,31 @@ public: SharedHandle getRange() const; - const std::string& getResponseStatus() const; + const std::string& getResponseStatus() const + { + return _responseStatus; + } void setResponseStatus(const std::string& responseStatus); - const std::string& getVersion() const; + const std::string& getVersion() const + { + return _version; + } void setVersion(const std::string& version); - const std::string& getMethod() const; + const std::string& getMethod() const + { + return _method; + } void setMethod(const std::string& method); - const std::string& getRequestPath() const; + const std::string& getRequestPath() const + { + return _requestPath; + } void setRequestPath(const std::string& requestPath); diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index bce4fd40..95630abd 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -37,7 +37,6 @@ #include #include -#include "Request.h" #include "Segment.h" #include "Range.h" #include "CookieStorage.h" @@ -59,11 +58,6 @@ HttpRequest::HttpRequest():entityLength(0), userAgent(USER_AGENT) {} -SharedHandle HttpRequest::getSegment() const -{ - return segment; -} - void HttpRequest::setSegment(const SharedHandle& segment) { this->segment = segment; @@ -74,11 +68,6 @@ void HttpRequest::setRequest(const SharedHandle& request) this->request = request; } -SharedHandle HttpRequest::getRequest() const -{ - return request; -} - off_t HttpRequest::getStartByte() const { if(segment.isNull()) { @@ -287,62 +276,12 @@ void HttpRequest::addAcceptType(const std::string& type) _acceptTypes.push_back(type); } -const std::string& HttpRequest::getPreviousURI() const -{ - return request->getPreviousUrl(); -} - -const std::string& HttpRequest::getHost() const -{ - return request->getHost(); -} - -uint16_t HttpRequest::getPort() const -{ - return request->getPort(); -} - -const std::string& HttpRequest::getMethod() const -{ - return request->getMethod(); -} - -const std::string& HttpRequest::getProtocol() const -{ - return request->getProtocol(); -} - -const std::string& HttpRequest::getCurrentURI() const -{ - return request->getCurrentUrl(); -} - -const std::string& HttpRequest::getDir() const -{ - return request->getDir(); -} - -const std::string& HttpRequest::getFile() const -{ - return request->getFile(); -} - -const std::string& HttpRequest::getQuery() const -{ - return request->getQuery(); -} - void HttpRequest::setCookieStorage (const SharedHandle& cookieStorage) { _cookieStorage = cookieStorage; } -SharedHandle HttpRequest::getCookieStorage() const -{ - return _cookieStorage; -} - void HttpRequest::setAuthConfigFactory (const SharedHandle& factory) { diff --git a/src/HttpRequest.h b/src/HttpRequest.h index d1eb9fdc..f84596a5 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -41,10 +41,10 @@ #include #include "SharedHandle.h" +#include "Request.h" namespace aria2 { -class Request; class Segment; class Range; class Option; @@ -85,7 +85,10 @@ private: public: HttpRequest(); - SharedHandle getSegment() const; + const SharedHandle& getSegment() const + { + return segment; + } void setSegment(const SharedHandle& segment); @@ -104,23 +107,50 @@ public: return entityLength; } - const std::string& getHost() const; + const std::string& getHost() const + { + return request->getHost(); + } - uint16_t getPort() const; + uint16_t getPort() const + { + return request->getPort(); + } - const std::string& getMethod() const; + const std::string& getMethod() const + { + return request->getMethod(); + } - const std::string& getProtocol() const; + const std::string& getProtocol() const + { + return request->getProtocol(); + } - const std::string& getCurrentURI() const; + const std::string& getCurrentURI() const + { + return request->getCurrentUrl(); + } - const std::string& getDir() const; + const std::string& getDir() const + { + return request->getDir(); + } - const std::string& getFile() const; + const std::string& getFile() const + { + return request->getFile(); + } - const std::string& getQuery() const; + const std::string& getQuery() const + { + return request->getQuery(); + } - const std::string& getPreviousURI() const; + const std::string& getPreviousURI() const + { + return request->getPreviousUrl(); + } SharedHandle getRange() const; @@ -130,7 +160,10 @@ public: */ bool isRangeSatisfied(const SharedHandle& range) const; - SharedHandle getRequest() const; + const SharedHandle& getRequest() const + { + return request; + } off_t getStartByte() const; @@ -173,7 +206,10 @@ public: void setCookieStorage(const SharedHandle& cookieStorage); - SharedHandle getCookieStorage() const; + const SharedHandle& getCookieStorage() const + { + return _cookieStorage; + } void setAuthConfigFactory(const SharedHandle& factory); diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index 0290207d..6d08c4b0 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -228,21 +228,11 @@ void HttpResponse::setHttpHeader(const SharedHandle& httpHeader) this->httpHeader = httpHeader; } -SharedHandle HttpResponse::getHttpHeader() const -{ - return httpHeader; -} - void HttpResponse::setHttpRequest(const SharedHandle& httpRequest) { this->httpRequest = httpRequest; } -SharedHandle HttpResponse::getHttpRequest() const -{ - return httpRequest; -} - // TODO return std::string const std::string& HttpResponse::getResponseStatus() const { diff --git a/src/HttpResponse.h b/src/HttpResponse.h index 78272bbb..d89a380f 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -102,13 +102,19 @@ public: void setHttpHeader(const SharedHandle& httpHeader); - SharedHandle getHttpHeader() const; + const SharedHandle& getHttpHeader() const + { + return httpHeader; + } const std::string& getResponseStatus() const; void setHttpRequest(const SharedHandle& httpRequest); - SharedHandle getHttpRequest() const; + const SharedHandle& getHttpRequest() const + { + return httpRequest; + } void setCuid(int32_t cuid) { diff --git a/src/LibsslTLSContext.cc b/src/LibsslTLSContext.cc index 58fc745b..ddcca08d 100644 --- a/src/LibsslTLSContext.cc +++ b/src/LibsslTLSContext.cc @@ -103,11 +103,6 @@ void TLSContext::addTrustedCACertFile(const std::string& certfile) } } -SSL_CTX* TLSContext::getSSLCtx() const -{ - return _sslCtx; -} - void TLSContext::enablePeerVerification() { _peerVerificationEnabled = true; @@ -118,9 +113,4 @@ void TLSContext::disablePeerVerification() _peerVerificationEnabled = false; } -bool TLSContext::peerVerificationEnabled() const -{ - return _peerVerificationEnabled; -} - } // namespace aria2 diff --git a/src/LibsslTLSContext.h b/src/LibsslTLSContext.h index 9f7aff39..6412f2fe 100644 --- a/src/LibsslTLSContext.h +++ b/src/LibsslTLSContext.h @@ -72,13 +72,20 @@ public: bool bad() const; - SSL_CTX* getSSLCtx() const; + SSL_CTX* getSSLCtx() const + { + return _sslCtx; + } void enablePeerVerification(); void disablePeerVerification(); - bool peerVerificationEnabled() const; + bool peerVerificationEnabled() const + { + return _peerVerificationEnabled; + } + }; } // namespace aria2 diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index 2b62cb9a..8653de09 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -590,44 +590,4 @@ size_t MSEHandshake::receiveNBytes(size_t bytes) return r; } -const unsigned char* MSEHandshake::getIA() const -{ - return _ia; -} - -size_t MSEHandshake::getIALength() const -{ - return _iaLength; -} - -const unsigned char* MSEHandshake::getInfoHash() const -{ - return _infoHash; -} - -MSEHandshake::CRYPTO_TYPE MSEHandshake::getNegotiatedCryptoType() const -{ - return _negotiatedCryptoType; -} - -SharedHandle MSEHandshake::getEncryptor() const -{ - return _encryptor; -} - -SharedHandle MSEHandshake::getDecryptor() const -{ - return _decryptor; -} - -const unsigned char* MSEHandshake::getBuffer() const -{ - return _rbuf; -} - -size_t MSEHandshake::getBufferLength() const -{ - return _rbufLength; -} - } // namespace aria2 diff --git a/src/MSEHandshake.h b/src/MSEHandshake.h index 6d4817f8..f2ceb3a7 100644 --- a/src/MSEHandshake.h +++ b/src/MSEHandshake.h @@ -167,21 +167,46 @@ public: bool sendReceiverStep2(); // returns plain text IA - const unsigned char* getIA() const; + const unsigned char* getIA() const + { + return _ia; + } - size_t getIALength() const; + size_t getIALength() const + { + return _iaLength; + } - const unsigned char* getInfoHash() const; + const unsigned char* getInfoHash() const + { + return _infoHash; + } - CRYPTO_TYPE getNegotiatedCryptoType() const; + CRYPTO_TYPE getNegotiatedCryptoType() const + { + return _negotiatedCryptoType; + } - SharedHandle getEncryptor() const; + const SharedHandle& getEncryptor() const + { + return _encryptor; + } - SharedHandle getDecryptor() const; + const SharedHandle& getDecryptor() const + { + return _decryptor; + } - const unsigned char* getBuffer() const; + const unsigned char* getBuffer() const + { + return _rbuf; + } + + size_t getBufferLength() const + { + return _rbufLength; + } - size_t getBufferLength() const; }; } // namespace aria2 diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc index 60bebcb9..056e3bbc 100644 --- a/src/MetalinkEntry.cc +++ b/src/MetalinkEntry.cc @@ -181,19 +181,9 @@ void MetalinkEntry::toFileEntry mem_fun_sh(&MetalinkEntry::getFile)); } -SharedHandle MetalinkEntry::getFile() const -{ - return file; -} - void MetalinkEntry::setSignature(const SharedHandle& signature) { _signature = signature; } -SharedHandle MetalinkEntry::getSignature() const -{ - return _signature; -} - } // namespace aria2 diff --git a/src/MetalinkEntry.h b/src/MetalinkEntry.h index 11ead2d8..042747ff 100644 --- a/src/MetalinkEntry.h +++ b/src/MetalinkEntry.h @@ -36,10 +36,12 @@ #define _D_METALINK_ENTRY_H_ #include "common.h" -#include "SharedHandle.h" + #include #include +#include "SharedHandle.h" + namespace aria2 { class MetalinkResource; @@ -75,7 +77,10 @@ public: uint64_t getLength() const; - SharedHandle getFile() const; + const SharedHandle& getFile() const + { + return file; + } void dropUnsupportedResource(); @@ -90,7 +95,11 @@ public: void setSignature(const SharedHandle& signature); - SharedHandle getSignature() const; + const SharedHandle& getSignature() const + { + return _signature; + } + }; } // namespace aria2 diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 4dd3eb6d..94a78d09 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -60,11 +60,6 @@ MetalinkParserController::MetalinkParserController(): MetalinkParserController::~MetalinkParserController() {} -SharedHandle MetalinkParserController::getResult() const -{ - return _metalinker; -} - void MetalinkParserController::newEntryTransaction() { _tEntry.reset(new MetalinkEntry()); diff --git a/src/MetalinkParserController.h b/src/MetalinkParserController.h index 216d6901..7811be23 100644 --- a/src/MetalinkParserController.h +++ b/src/MetalinkParserController.h @@ -79,7 +79,10 @@ public: ~MetalinkParserController(); - SharedHandle getResult() const; + const SharedHandle& getResult() const + { + return _metalinker; + } void newEntryTransaction(); diff --git a/src/MetalinkParserStateMachine.cc b/src/MetalinkParserStateMachine.cc index 4a29ae9b..40595723 100644 --- a/src/MetalinkParserStateMachine.cc +++ b/src/MetalinkParserStateMachine.cc @@ -33,7 +33,6 @@ */ /* copyright --> */ #include "MetalinkParserStateMachine.h" -#include "MetalinkParserController.h" #include "InitialMetalinkParserState.h" #include "MetalinkMetalinkParserState.h" #include "FilesMetalinkParserState.h" @@ -368,9 +367,4 @@ bool MetalinkParserStateMachine::needsCharactersBuffering() const return _state->needsCharactersBuffering(); } -SharedHandle MetalinkParserStateMachine::getResult() const -{ - return _ctrl->getResult(); -} - } // namespace aria2 diff --git a/src/MetalinkParserStateMachine.h b/src/MetalinkParserStateMachine.h index bd022f53..06161a80 100644 --- a/src/MetalinkParserStateMachine.h +++ b/src/MetalinkParserStateMachine.h @@ -36,13 +36,14 @@ #define _D_METALINK_PARSER_STATE_MACHINE_H_ #include "common.h" -#include "SharedHandle.h" #include #include +#include "SharedHandle.h" +#include "MetalinkParserController.h" + namespace aria2 { -class MetalinkParserController; class MetalinkParserState; class SkipTagMetalinkParserState; class Metalinker; @@ -191,7 +192,10 @@ public: bool needsCharactersBuffering() const; - SharedHandle getResult() const; + const SharedHandle& getResult() const + { + return _ctrl->getResult(); + } }; } // namespace aria2 diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index ea8e6461..7083de7f 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -96,11 +96,6 @@ void DiskWriterEntry::openExistingFile() } } -bool DiskWriterEntry::isOpen() const -{ - return _open; -} - void DiskWriterEntry::closeFile() { if(_open) { @@ -119,21 +114,11 @@ uint64_t DiskWriterEntry::size() const return File(getFilePath()).size(); } -SharedHandle DiskWriterEntry::getFileEntry() const -{ - return fileEntry; -} - void DiskWriterEntry::setDiskWriter(const SharedHandle& diskWriter) { this->diskWriter = diskWriter; } -SharedHandle DiskWriterEntry::getDiskWriter() const -{ - return diskWriter; -} - bool DiskWriterEntry::operator<(const DiskWriterEntry& entry) const { return fileEntry < entry.fileEntry; @@ -155,16 +140,6 @@ void DiskWriterEntry::disableDirectIO() _directIO = false; } -bool DiskWriterEntry::needsFileAllocation() const -{ - return _needsFileAllocation; -} - -void DiskWriterEntry::needsFileAllocation(bool f) -{ - _needsFileAllocation = f; -} - MultiDiskAdaptor::MultiDiskAdaptor(): pieceLength(0), _maxOpenFiles(DEFAULT_MAX_OPEN_FILES), @@ -552,10 +527,4 @@ size_t MultiDiskAdaptor::utime(const Time& actime, const Time& modtime) return numOK; } -const std::deque >& -MultiDiskAdaptor::getDiskWriterEntries() const -{ - return diskWriterEntries; -} - } // namespace aria2 diff --git a/src/MultiDiskAdaptor.h b/src/MultiDiskAdaptor.h index a9e0f09f..21018259 100644 --- a/src/MultiDiskAdaptor.h +++ b/src/MultiDiskAdaptor.h @@ -65,17 +65,26 @@ public: void closeFile(); - bool isOpen() const; + bool isOpen() const + { + return _open; + } bool fileExists(); uint64_t size() const; - SharedHandle getFileEntry() const; + const SharedHandle& getFileEntry() const + { + return fileEntry; + } void setDiskWriter(const SharedHandle& diskWriter); - SharedHandle getDiskWriter() const; + const SharedHandle& getDiskWriter() const + { + return diskWriter; + } bool operator<(const DiskWriterEntry& entry) const; @@ -89,9 +98,16 @@ public: // called. void disableDirectIO(); - bool needsFileAllocation() const; + bool needsFileAllocation() const + { + return _needsFileAllocation; + } + + void needsFileAllocation(bool f) + { + _needsFileAllocation = f; + } - void needsFileAllocation(bool f); }; typedef SharedHandle DiskWriterEntryHandle; @@ -177,7 +193,11 @@ public: virtual size_t utime(const Time& actime, const Time& modtime); const std::deque >& - getDiskWriterEntries() const; + getDiskWriterEntries() const + { + return diskWriterEntries; + } + }; typedef SharedHandle MultiDiskAdaptorHandle; diff --git a/src/NetrcAuthResolver.cc b/src/NetrcAuthResolver.cc index 6a77d16d..6ebcf2fe 100644 --- a/src/NetrcAuthResolver.cc +++ b/src/NetrcAuthResolver.cc @@ -73,11 +73,6 @@ void NetrcAuthResolver::setNetrc(const NetrcHandle& netrc) _netrc = netrc; } -NetrcHandle NetrcAuthResolver::getNetrc() const -{ - return _netrc; -} - void NetrcAuthResolver::ignoreDefault() { _ignoreDefault = true; diff --git a/src/NetrcAuthResolver.h b/src/NetrcAuthResolver.h index 290dcbe7..812f6795 100644 --- a/src/NetrcAuthResolver.h +++ b/src/NetrcAuthResolver.h @@ -57,7 +57,10 @@ public: void setNetrc(const SharedHandle& netrc); - SharedHandle getNetrc() const; + const SharedHandle& getNetrc() const + { + return _netrc; + } // Ignores default token of netrc void ignoreDefault(); diff --git a/src/Peer.cc b/src/Peer.cc index 41920266..63919ba1 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -71,36 +71,11 @@ Peer::~Peer() releaseSessionResource(); } -bool Peer::operator==(const Peer& p) -{ - return id == p.id; -} - -bool Peer::operator!=(const Peer& p) -{ - return !(*this == p); -} - -const std::string& Peer::getID() const -{ - return id; -} - void Peer::usedBy(int32_t cuid) { _cuid = cuid; } -int32_t Peer::usedBy() const -{ - return _cuid; -} - -bool Peer::unused() const -{ - return _cuid == 0; -} - void Peer::allocateSessionResource(size_t pieceLength, uint64_t totalLength) { delete _res; @@ -114,21 +89,11 @@ void Peer::releaseSessionResource() _res = 0; } -bool Peer::isActive() const -{ - return _res != 0; -} - void Peer::setPeerId(const unsigned char* peerId) { memcpy(_peerId, peerId, PEER_ID_LENGTH); } -const unsigned char* Peer::getPeerId() const -{ - return _peerId; -} - void Peer::resetStatus() { _cuid = 0; } @@ -432,21 +397,6 @@ bool Peer::isDHTEnabled() const return _res->dhtEnabled(); } -bool Peer::isSeeder() const -{ - return _seeder; -} - -const Time& Peer::getFirstContactTime() const -{ - return _firstContactTime; -} - -const Time& Peer::getBadConditionStartTime() const -{ - return _badConditionStartTime; -} - const Time& Peer::getLastDownloadUpdate() const { assert(_res); @@ -465,11 +415,6 @@ uint64_t Peer::getCompletedLength() const return _res->getCompletedLength(); } -bool Peer::isIncomingPeer() const -{ - return _incoming; -} - void Peer::setIncomingPeer(bool incoming) { _incoming = incoming; diff --git a/src/Peer.h b/src/Peer.h index 506bb937..3ec820ae 100644 --- a/src/Peer.h +++ b/src/Peer.h @@ -36,12 +36,15 @@ #define _D_PEER_H_ #include "common.h" + +#include +#include +#include + #include "SharedHandle.h" #include "TimeA2.h" #include "BtConstants.h" #include "PeerStat.h" -#include -#include namespace aria2 { @@ -82,28 +85,52 @@ public: ~Peer(); - bool operator==(const Peer& p); + bool operator==(const Peer& p) + { + return id == p.id; + } - bool operator!=(const Peer& p); + bool operator!=(const Peer& p) + { + return !(*this == p); + } void resetStatus(); void usedBy(int32_t cuid); - int32_t usedBy() const; + int32_t usedBy() const + { + return _cuid; + } - bool unused() const; + bool unused() const + { + return _cuid == 0; + } // Returns true iff _res != 0. - bool isActive() const; + bool isActive() const + { + return _res != 0; + } void setPeerId(const unsigned char* peerId); - const unsigned char* getPeerId() const; + const unsigned char* getPeerId() const + { + return _peerId; + } - bool isSeeder() const; + bool isSeeder() const + { + return _seeder; + } - const std::string& getID() const; + const std::string& getID() const + { + return id; + } void startBadCondition(); @@ -113,11 +140,17 @@ public: void releaseSessionResource(); - const Time& getFirstContactTime() const; + const Time& getFirstContactTime() const + { + return _firstContactTime; + } void setFirstContactTime(const Time& time); - const Time& getBadConditionStartTime() const; + const Time& getBadConditionStartTime() const + { + return _badConditionStartTime; + } // Before calling following member functions, make sure that // allocateSessionResource() is called and _res is created. @@ -244,7 +277,10 @@ public: uint64_t getCompletedLength() const; - bool isIncomingPeer() const; + bool isIncomingPeer() const + { + return _incoming; + } void setIncomingPeer(bool incoming); diff --git a/src/PeerSessionResource.cc b/src/PeerSessionResource.cc index a35ceadb..8c8849e8 100644 --- a/src/PeerSessionResource.cc +++ b/src/PeerSessionResource.cc @@ -66,11 +66,6 @@ PeerSessionResource::~PeerSessionResource() delete _bitfieldMan; } -bool PeerSessionResource::amChoking() const -{ - return _amChoking; -} - void PeerSessionResource::amChoking(bool b) { _amChoking = b; @@ -79,51 +74,26 @@ void PeerSessionResource::amChoking(bool b) } } -bool PeerSessionResource::amInterested() const -{ - return _amInterested; -} - void PeerSessionResource::amInterested(bool b) { _amInterested = b; } -bool PeerSessionResource::peerChoking() const -{ - return _peerChoking; -} - void PeerSessionResource::peerChoking(bool b) { _peerChoking = b; } -bool PeerSessionResource::peerInterested() const -{ - return _peerInterested; -} - void PeerSessionResource::peerInterested(bool b) { _peerInterested = b; } -bool PeerSessionResource::chokingRequired() const -{ - return _chokingRequired; -} - void PeerSessionResource::chokingRequired(bool b) { _chokingRequired = b; } -bool PeerSessionResource::optUnchoking() const -{ - return _optUnchoking; -} - void PeerSessionResource::optUnchoking(bool b) { _optUnchoking = b; @@ -137,11 +107,6 @@ bool PeerSessionResource::shouldBeChoking() const return _chokingRequired; } -bool PeerSessionResource::snubbing() const -{ - return _snubbing; -} - void PeerSessionResource::snubbing(bool b) { _snubbing = b; @@ -190,11 +155,6 @@ void PeerSessionResource::markSeeder() _bitfieldMan->setAllBit(); } -bool PeerSessionResource::fastExtensionEnabled() const -{ - return _fastExtensionEnabled; -} - void PeerSessionResource::fastExtensionEnabled(bool b) { _fastExtensionEnabled = b; @@ -225,11 +185,6 @@ bool PeerSessionResource::peerAllowedIndexSetContains(size_t index) const index); } -const std::deque& PeerSessionResource::amAllowedIndexSet() const -{ - return _amAllowedIndexSet; -} - void PeerSessionResource::addAmAllowedIndex(size_t index) { updateIndexSet(_amAllowedIndexSet, index); @@ -242,11 +197,6 @@ bool PeerSessionResource::amAllowedIndexSetContains(size_t index) const index); } -bool PeerSessionResource::extendedMessagingEnabled() const -{ - return _extendedMessagingEnabled; -} - void PeerSessionResource::extendedMessagingEnabled(bool b) { _extendedMessagingEnabled = b; @@ -280,26 +230,11 @@ void PeerSessionResource::addExtension(const std::string& name, uint8_t id) _extensions[name] = id; } -bool PeerSessionResource::dhtEnabled() const -{ - return _dhtEnabled; -} - void PeerSessionResource::dhtEnabled(bool b) { _dhtEnabled = b; } -PeerStat& PeerSessionResource::getPeerStat() -{ - return _peerStat; -} - -unsigned int PeerSessionResource::latency() const -{ - return _latency; -} - void PeerSessionResource::updateLatency(unsigned int latency) { _latency = _latency*0.2+latency*0.8; @@ -327,16 +262,6 @@ void PeerSessionResource::updateDownloadLength(size_t bytes) _lastDownloadUpdate.reset(); } -const Time& PeerSessionResource::getLastDownloadUpdate() const -{ - return _lastDownloadUpdate; -} - -const Time& PeerSessionResource::getLastAmUnchoking() const -{ - return _lastAmUnchoking; -} - uint64_t PeerSessionResource::getCompletedLength() const { return _bitfieldMan->getCompletedLength(); diff --git a/src/PeerSessionResource.h b/src/PeerSessionResource.h index f0828c0e..cfe148af 100644 --- a/src/PeerSessionResource.h +++ b/src/PeerSessionResource.h @@ -87,39 +87,60 @@ public: ~PeerSessionResource(); // localhost is choking this peer - bool amChoking() const; + bool amChoking() const + { + return _amChoking; + } void amChoking(bool b); // localhost is interested in this peer - bool amInterested() const; + bool amInterested() const + { + return _amInterested; + } void amInterested(bool b); // this peer is choking localhost - bool peerChoking() const; + bool peerChoking() const + { + return _peerChoking; + } void peerChoking(bool b); // this peer is interested in localhost - bool peerInterested() const; + bool peerInterested() const + { + return _peerInterested; + } void peerInterested(bool b); // this peer should be choked - bool chokingRequired() const; + bool chokingRequired() const + { + return _chokingRequired; + } void chokingRequired(bool b); // this peer is eligible for unchoking optionally. - bool optUnchoking() const; + bool optUnchoking() const + { + return _optUnchoking; + } void optUnchoking(bool b); bool shouldBeChoking() const; // this peer is snubbing. - bool snubbing() const; + bool snubbing() const + { + return _snubbing; + } void snubbing(bool b); @@ -137,7 +158,10 @@ public: void markSeeder(); - bool fastExtensionEnabled() const; + bool fastExtensionEnabled() const + { + return _fastExtensionEnabled; + } void fastExtensionEnabled(bool b); @@ -149,13 +173,19 @@ public: bool peerAllowedIndexSetContains(size_t index) const; // fast index set which localhost has sent to a peer. - const std::deque& amAllowedIndexSet() const; + const std::deque& amAllowedIndexSet() const + { + return _amAllowedIndexSet; + } void addAmAllowedIndex(size_t index); bool amAllowedIndexSetContains(size_t index) const; - bool extendedMessagingEnabled() const; + bool extendedMessagingEnabled() const + { + return _extendedMessagingEnabled; + } void extendedMessagingEnabled(bool b); @@ -165,13 +195,22 @@ public: void addExtension(const std::string& name, uint8_t id); - bool dhtEnabled() const; + bool dhtEnabled() const + { + return _dhtEnabled; + } void dhtEnabled(bool b); - PeerStat& getPeerStat(); + PeerStat& getPeerStat() + { + return _peerStat; + } - unsigned int latency() const; + unsigned int latency() const + { + return _latency; + } void updateLatency(unsigned int latency); @@ -183,9 +222,15 @@ public: void updateDownloadLength(size_t bytes); - const Time& getLastDownloadUpdate() const; + const Time& getLastDownloadUpdate() const + { + return _lastDownloadUpdate; + } - const Time& getLastAmUnchoking() const; + const Time& getLastAmUnchoking() const + { + return _lastAmUnchoking; + } uint64_t getCompletedLength() const; diff --git a/src/Piece.cc b/src/Piece.cc index 3339410c..4f2bfcc2 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -95,16 +95,6 @@ Piece& Piece::operator=(const Piece& piece) return *this; } -bool Piece::operator==(const Piece& piece) const -{ - return index == piece.index; -} - -bool Piece::operator<(const Piece& piece) const -{ - return index < piece.index; -} - void Piece::completeBlock(size_t blockIndex) { bitfield->setBit(blockIndex); bitfield->unsetUseBit(blockIndex); diff --git a/src/Piece.h b/src/Piece.h index caa5b1d4..b220be5a 100644 --- a/src/Piece.h +++ b/src/Piece.h @@ -82,9 +82,15 @@ public: Piece& operator=(const Piece& piece); - bool operator==(const Piece& piece) const; + bool operator==(const Piece& piece) const + { + return index == piece.index; + } - bool operator<(const Piece& piece) const; + bool operator<(const Piece& piece) const + { + return index < piece.index; + } bool getMissingUnusedBlockIndex(size_t& index) const; bool getMissingBlockIndex(size_t& index) const; diff --git a/src/PieceStatMan.cc b/src/PieceStatMan.cc index 1afdf929..9da7302e 100644 --- a/src/PieceStatMan.cc +++ b/src/PieceStatMan.cc @@ -42,15 +42,6 @@ namespace aria2 { PieceStat::PieceStat(size_t index):_order(0), _index(index), _count(0) {} -bool PieceStat::operator<(const PieceStat& pieceStat) const -{ - if(_count == pieceStat._count) { - return _order < pieceStat._order; - } else { - return _count < pieceStat._count; - } -} - void PieceStat::addCount() { if(_count < SIZE_MAX) { @@ -65,26 +56,6 @@ void PieceStat::subCount() } } -size_t PieceStat::getIndex() const -{ - return _index; -} - -size_t PieceStat::getCount() const -{ - return _count; -} - -void PieceStat::setOrder(size_t order) -{ - _order = order; -} - -size_t PieceStat::getOrder() const -{ - return _order; -} - class GenPieceStat { private: size_t _index; @@ -204,15 +175,4 @@ void PieceStatMan::addPieceStats(size_t index) std::rotate(cur, cur+1, to); } -const std::vector& PieceStatMan::getRarerPieceIndexes() const -{ - return _sortedPieceStatIndexes; -} - -const std::vector >& -PieceStatMan::getPieceStats() const -{ - return _pieceStats; -} - } // namespace aria2 diff --git a/src/PieceStatMan.h b/src/PieceStatMan.h index 45c26ffe..b5f038be 100644 --- a/src/PieceStatMan.h +++ b/src/PieceStatMan.h @@ -51,15 +51,38 @@ private: public: PieceStat(size_t index); - bool operator<(const PieceStat& pieceStat) const; + bool operator<(const PieceStat& pieceStat) const + { + if(_count == pieceStat._count) { + return _order < pieceStat._order; + } else { + return _count < pieceStat._count; + } + } void addCount(); void subCount(); - size_t getOrder() const; - void setOrder(size_t order); - size_t getIndex() const; - size_t getCount() const; + size_t getOrder() const + { + return _order; + } + + void setOrder(size_t order) + { + _order = order; + } + + size_t getIndex() const + { + return _index; + } + + size_t getCount() const + { + return _count; + } + }; class PieceStatMan { @@ -83,9 +106,16 @@ public: const unsigned char* oldBitfield); // Returns piece index in rarest first order. - const std::vector& getRarerPieceIndexes() const; + const std::vector& getRarerPieceIndexes() const + { + return _sortedPieceStatIndexes; + } + + const std::vector >& getPieceStats() const + { + return _pieceStats; + } - const std::vector >& getPieceStats() const; }; } // namespace aria2 diff --git a/src/Request.cc b/src/Request.cc index 2e6439a0..82b8b56b 100644 --- a/src/Request.cc +++ b/src/Request.cc @@ -238,24 +238,9 @@ void Request::resetRedirectCount() _redirectCount = 0; } -unsigned int Request::getRedirectCount() const -{ - return _redirectCount; -} - -bool Request::isPipeliningHint() const -{ - return _pipeliningHint; -} - void Request::setMaxPipelinedRequest(unsigned int num) { _maxPipelinedRequest = num; } -unsigned int Request::getMaxPipelinedRequest() const -{ - return _maxPipelinedRequest; -} - } // namespace aria2 diff --git a/src/Request.h b/src/Request.h index f637ca19..227d9e22 100644 --- a/src/Request.h +++ b/src/Request.h @@ -100,7 +100,10 @@ public: void resetRedirectCount(); - unsigned int getRedirectCount() const; + unsigned int getRedirectCount() const + { + return _redirectCount; + } // Returns URI passed by setUrl() const std::string& getUrl() const { return url; } @@ -145,11 +148,17 @@ public: _pipeliningHint = pipeliningHint; } - bool isPipeliningHint() const; + bool isPipeliningHint() const + { + return _pipeliningHint; + } void setMaxPipelinedRequest(unsigned int num); - unsigned int getMaxPipelinedRequest() const; + unsigned int getMaxPipelinedRequest() const + { + return _maxPipelinedRequest; + } void setMethod(const std::string& method) { this->method = method; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 291b13c2..3244129b 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -149,7 +149,7 @@ RequestGroup::RequestGroup(const SharedHandle