libktorrent  2.1.1
peeruploader.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTPEERUPLOADER_H
21 #define BTPEERUPLOADER_H
22 
23 #include <qlist.h>
24 #include <download/request.h>
25 
26 
27 
28 namespace bt
29 {
30  class Peer;
31  class ChunkManager;
32 
33  const Uint32 ALLOWED_FAST_SIZE = 8;
34 
44  class PeerUploader
45  {
46  Peer* peer;
47  QList<Request> requests;
48  Uint32 uploaded;
49  public:
54  PeerUploader(Peer* peer);
55  virtual ~PeerUploader();
56 
61  void addRequest(const Request & r);
62 
67  void removeRequest(const Request & r);
68 
75  Uint32 handleRequests(bt::ChunkManager& cman);
76 
78  Uint32 getNumRequests() const;
79 
80 
81  void addUploadedBytes(Uint32 bytes) {uploaded += bytes;}
82 
86  void clearAllRequests();
87  };
88 
89 }
90 
91 #endif
bt::PeerUploader::PeerUploader
PeerUploader(Peer *peer)
bt::PeerUploader::addRequest
void addRequest(const Request &r)
bt::PeerUploader::handleRequests
Uint32 handleRequests(bt::ChunkManager &cman)
bt::ChunkManager
Definition: chunkmanager.h:61
bt::PeerUploader::removeRequest
void removeRequest(const Request &r)
bt::Request
Request of a piece sent to other peers.
Definition: request.h:58
bt::PeerUploader::clearAllRequests
void clearAllRequests()
bt::PeerUploader::getNumRequests
Uint32 getNumRequests() const
Get the number of requests.