libktorrent  2.2.0
request.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 BTREQUEST_H
21 #define BTREQUEST_H
22 
23 #include <util/constants.h>
24 
25 namespace bt
26 {
27  class PieceDownloader;
28 
39  class Request
40  {
41  public:
45  inline Request(): index(0),off(0),len(0),pd(0) {}
46 
54  inline Request(Uint32 index,Uint32 off,Uint32 len,PieceDownloader* pd)
55  : index(index),off(off),len(len),pd(pd) {}
56 
61  inline Request(const Request & r): index(r.index),off(r.off),len(r.len),pd(r.pd) {}
62  ~Request(){}
63 
65  Uint32 getIndex() const {return index;}
66 
68  Uint32 getOffset() const {return off;}
69 
71  Uint32 getLength() const {return len;}
72 
74  inline PieceDownloader* getPieceDownloader() const {return pd;}
75 
80  inline Request & operator = (const Request & r)
81  {
82  index = r.index;
83  off = r.off;
84  len = r.len;
85  pd = r.pd;
86  return *this;
87  }
88 
89 
97  friend inline bool operator == (const Request & a,const Request & b)
98  {
99  return a.index == b.index && a.len == b.len && a.off == b.off;
100  }
101  private:
102  Uint32 index,off,len;
103  PieceDownloader* pd;
104  };
105 
106 }
107 
108 #endif
bt::PieceDownloader
Definition: piecedownloader.h:57
bt::Request::operator=
Request & operator=(const Request &r)
Definition: request.h:98
bt::Request::operator==
friend bool operator==(const Request &a, const Request &b)
Definition: request.h:115
bt::Request::Request
Request()
Definition: request.h:63
bt::Request
Request of a piece sent to other peers.
Definition: request.h:58
bt::Request::getPieceDownloader
PieceDownloader * getPieceDownloader() const
Get the sending Peer.
Definition: request.h:92
bt::Request::getOffset
Uint32 getOffset() const
Get the offset into the chunk.
Definition: request.h:86
bt::Request::getIndex
Uint32 getIndex() const
Get the index of the chunk.
Definition: request.h:83
bt::Request::getLength
Uint32 getLength() const
Get the length of a the piece.
Definition: request.h:89