/* */ #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) { const BDE& attrs = (*i).second._downloadContext->getAttribute(bittorrent::BITTORRENT); if(attrs[bittorrent::INFO_HASH].s() == 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