/* */ #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(int32_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(); i != _pool.end(); ++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(int32_t gid, const BtObject& obj) { _pool[gid] = obj; } BtObject BtRegistry::get(int32_t gid) const { std::map::const_iterator i = _pool.find(gid); if(i == _pool.end()) { return BtObject(); } else { return (*i).second; } } bool BtRegistry::remove(int32_t gid) { return _pool.erase(gid); } void BtRegistry::removeAll() { _pool.clear(); } } // namespace aria2