/* */ #ifndef _D_PEER_STORAGE_H_ #define _D_PEER_STORAGE_H_ #include "common.h" #include "Peer.h" #include "TransferStat.h" class PeerStorage { public: virtual ~PeerStorage() {} /** * Adds new peer to the internal peer list. * If the peer is added successfully, returns true. Otherwise returns false. */ virtual bool addPeer(const PeerHandle& peer) = 0; /** * Adds all peers in peers to internal peer list. */ virtual void addPeer(const Peers& peers) = 0; /** * Returns internal peer list. */ virtual const Peers& getPeers() = 0; /** * Returns one of the unused peers. */ virtual PeerHandle getUnusedPeer() = 0; /** * Returns true if at least one unused peer exists. * Otherwise returns false. */ virtual bool isPeerAvailable() = 0; /** * Returns the list of peers which are currently connected from localhost. */ virtual Peers getActivePeers() = 0; /** * Calculates current download/upload statistics. */ virtual TransferStat calculateStat() = 0; /** * Tells PeerStorage object that peer is no longer used in the session. */ virtual void returnPeer(const PeerHandle& peer) = 0; }; typedef SharedHandle PeerStorageHandle; #endif // _D_PEER_STORAGE_H_