#ifndef _D_MOCK_PEER_STORAGE_H_ #define _D_MOCK_PEER_STORAGE_H_ #include "PeerStorage.h" #include #include "Peer.h" namespace aria2 { class MockPeerStorage : public PeerStorage { private: TransferStat stat; std::deque > peers; std::vector > activePeers; int _numChokeExecuted; public: MockPeerStorage():_numChokeExecuted(0) {} virtual ~MockPeerStorage() {} virtual bool addPeer(const SharedHandle& peer) { peers.push_back(peer); return true; } virtual void addPeer(const std::vector >& peers) { std::copy(peers.begin(), peers.end(), back_inserter(this->peers)); } virtual const std::deque >& getPeers() { return peers; } virtual SharedHandle getUnusedPeer() { return SharedHandle(); } virtual bool isPeerAvailable() { return false; } void setActivePeers(const std::vector >& activePeers) { this->activePeers = activePeers; } virtual void getActivePeers(std::vector >& peers) { peers.insert(peers.end(), activePeers.begin(), activePeers.end()); } virtual TransferStat calculateStat() { return stat; } void setStat(const TransferStat& stat) { this->stat = stat; } virtual void returnPeer(const SharedHandle& peer) { } virtual bool chokeRoundIntervalElapsed() { return false; } virtual void executeChoke() { ++_numChokeExecuted; } virtual void updateTransferStatFor(const SharedHandle& peer) {} virtual TransferStat getTransferStatFor(const SharedHandle& peer) { return TransferStat(); } int getNumChokeExecuted() const { return _numChokeExecuted; } }; #endif // _D_MOCK_PEER_STORAGE_H_ } // namespace aria2