kget
btchunkselector.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 00003 Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 */ 00010 00011 #ifndef KGETBTCHUNKSELECTOR_H 00012 #define KGETBTCHUNKSELECTOR_H 00013 00014 #include <list> 00015 #include <util/timer.h> 00016 #include <util/constants.h> 00017 #include <interfaces/chunkselectorinterface.h> 00018 #include <QObject> 00019 00020 namespace bt 00021 { 00022 class BitSet; 00023 class ChunkManager; 00024 class Downloader; 00025 class PeerManager; 00026 class PieceDownloader; 00027 } 00028 00029 class BTChunkSelector : public bt::ChunkSelectorInterface 00030 { 00031 public: 00032 BTChunkSelector(bt::ChunkManager & cman,bt::Downloader & downer,bt::PeerManager & pman); 00033 ~BTChunkSelector(); 00034 00035 virtual bool select(bt::PieceDownloader* pd,bt::Uint32 & chunk); 00036 virtual void dataChecked(const bt::BitSet & ok_chunks); 00037 virtual void reincluded(bt::Uint32 from, bt::Uint32 to); 00038 virtual void reinsert(bt::Uint32 chunk); 00039 virtual void excludeAll(); 00040 virtual void exclude(bt::Uint32 chunk); 00041 00042 private: 00043 bt::Uint32 leastPeers(const std::list<bt::Uint32> & lp); 00044 00045 std::list<bt::Uint32> chunks; 00046 bt::Timer sort_timer; 00047 }; 00048 00049 class BTChunkSelectorFactory : public QObject, public bt::ChunkSelectorFactoryInterface 00050 { 00051 Q_OBJECT 00052 public: 00053 BTChunkSelectorFactory(); 00054 ~BTChunkSelectorFactory(); 00055 00056 bt::ChunkSelectorInterface* createChunkSelector(bt::ChunkManager & cman, bt::Downloader & downer, bt::PeerManager & pman); 00057 00058 signals: 00059 void selectorAdded(BTChunkSelector *selector); 00060 }; 00061 00062 #endif
KDE 4.2 API Reference