#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::deque > droppedPeers; 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 size_t countPeer() const { return peers.size(); } virtual const std::deque >& getDroppedPeers() { return droppedPeers; } void addDroppedPeer(const SharedHandle& peer) { droppedPeers.push_back(peer); } 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