/* */ #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; class LpdMessageReceiver; 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_; uint16_t tcpPort_; SharedHandle lpdMessageReceiver_; public: BtRegistry(); ~BtRegistry(); 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); void setTcpPort(uint16_t port) { tcpPort_ = port; } uint16_t getTcpPort() const { return tcpPort_; } void setLpdMessageReceiver(const SharedHandle& receiver); const SharedHandle& getLpdMessageReceiver() const { return lpdMessageReceiver_; } }; } // namespace aria2 #endif // D_BT_REGISTRY_H