/* */ #include "BtRegistry.h" #include "DlAbortEx.h" #include "DownloadContext.h" #include "PeerStorage.h" #include "PieceStorage.h" #include "BtAnnounce.h" #include "BtRuntime.h" #include "BtProgressInfoFile.h" #include "bittorrent_helper.h" namespace aria2 { SharedHandle BtRegistry::getDownloadContext(gid_t gid) const { return get(gid).downloadContext_; } SharedHandle BtRegistry::getDownloadContext(const std::string& infoHash) const { SharedHandle dctx; for(std::map::const_iterator i = pool_.begin(), eoi = pool_.end(); i != eoi; ++i) { if(bittorrent::getTorrentAttrs((*i).second.downloadContext_)->infoHash == infoHash) { dctx = (*i).second.downloadContext_; break; } } return dctx; } void BtRegistry::put(gid_t gid, const BtObject& obj) { pool_[gid] = obj; } BtObject BtRegistry::get(gid_t gid) const { std::map::const_iterator i = pool_.find(gid); if(i == pool_.end()) { return BtObject(); } else { return (*i).second; } } bool BtRegistry::remove(gid_t gid) { return pool_.erase(gid); } void BtRegistry::removeAll() { pool_.clear(); } } // namespace aria2