/* */ #ifndef D_BT_REGISTRY_H #define D_BT_REGISTRY_H #include "common.h" #include #include "SharedHandle.h" #include "RequestGroup.h" namespace aria2 { class PeerStorage; class PieceStorage; class BtAnnounce; class BtRuntime; class BtProgressInfoFile; class DownloadContext; struct BtObject { SharedHandle downloadContext_; SharedHandle pieceStorage_; SharedHandle peerStorage_; SharedHandle btAnnounce_; SharedHandle btRuntime_; SharedHandle btProgressInfoFile_; BtObject(const SharedHandle& downloadContext, const SharedHandle& pieceStorage, const SharedHandle& peerStorage, const SharedHandle& btAnnounce, const SharedHandle& btRuntime, const SharedHandle& btProgressInfoFile); BtObject(); BtObject(const BtObject& c); ~BtObject(); BtObject& operator=(const BtObject& c); bool isNull() const; }; class BtRegistry { private: std::map pool_; public: SharedHandle getDownloadContext(a2_gid_t gid) const; SharedHandle getDownloadContext(const std::string& infoHash) const; void put(a2_gid_t gid, const BtObject& obj); BtObject get(a2_gid_t gid) const; template OutputIterator getAllDownloadContext(OutputIterator dest) { for(std::map::const_iterator i = pool_.begin(), eoi = pool_.end(); i != eoi; ++i) { *dest++ = (*i).second.downloadContext_; } return dest; } void removeAll(); bool remove(a2_gid_t gid); }; } // namespace aria2 #endif // D_BT_REGISTRY_H