Protocols::BitTorrent::Trackers::TrackerRequest Class Reference

#include <TrackerRequest.h> [code]

List of all members.


Detailed Description

Represents tracker request arguments.

This class is used to store all needed tracker request arguments. It provides value semantics (objects copying is allowed) and implicit data sharing.

Stored tracker request arguments are made according to this specification: http://wiki.theory.org/BitTorrentSpecification#Tracker_Request_Parameters . It stores also tracker announce URL, because it's related to the TrackerRequest, so you need to create a separate tracker request for each announce URL (if needed).

Note:
The specification doesn't mention the format of the 'compact' and the 'key' parameter so it's implemented as a QByteArray and bool, respectively.
It does not throw its own exceptions and lets any thrown exceptions through to the user. In case an exception (e.g. bad_alloc) gets thrown, the TrackerRequest object will be left in an unchanged state. Thus the class meets the strong guarantee of exception safety.

Todo:
Remove the first parameter (announceUrl) from the ctor? We added it since we needed to pass it anyway with the request, but the situation has changed because with the new TrackerRequestSession interface (and considering the TrackerRequestSessionFactory/TrackerManager classes)
  • it won't be necessary to have it there. And because the TrackerManager creates its own requests, but it doesn't know to which tracker the session is connected, it may be even impossible to have this parameter there!

Definition at line 64 of file TrackerRequest.h.

Public Types

enum  Event {
  Empty = 0,
  Started,
  Completed,
  Stopped
}
 Specifies the reason for the peer that is contacting the tracker. More...

Public Member Functions

 TrackerRequest (const TrackerRequest &)
 Copy constructor.
TrackerRequestoperator= (const TrackerRequest &)
 Assignment operator.
bool operator== (const TrackerRequest &) const
 Equality comparison.
bool operator!= (const TrackerRequest &) const
 Inequality comparison.
 TrackerRequest (const Uri &announceUrl, const PeerInfo &peerInfo, const Torrent::InfoHash &infoHash, quint64 uploaded, quint64 downloaded, quint64 left, bool compact, Event event=Empty, uint numWant=0, QByteArray key=QByteArray(), QByteArray trackerId=QByteArray())
 ~TrackerRequest ()
 Destructor.
Uri announceUrl () const
PeerInfo peerInfo () const
Torrent::InfoHash infoHash () const
quint64 uploaded () const
quint64 downloaded () const
quint64 left () const
bool compact () const
Event event () const
uint numWant () const
QByteArray key () const
QByteArray trackerId () const

Private Attributes

QSharedDataPointer< PrivateDatad
 Private data with implicit sharing.

Classes

struct  PrivateData
 Stores the private members of TrackerRequest using implicit sharing. More...


Member Enumeration Documentation

enum Protocols::BitTorrent::Trackers::TrackerRequest::Event
 

Specifies the reason for the peer that is contacting the tracker.

Enumerator:
Empty  Not present.
Started  Download begins.
Completed  Download is complete.
Stopped  Downloader ceased downloading.

Definition at line 71 of file TrackerRequest.h.


Constructor & Destructor Documentation

TrackerRequest::TrackerRequest const TrackerRequest other  ) 
 

Copy constructor.

Parameters:
other Object that will be used as a model in the object creation.
Constructs a copy of the other object.

Definition at line 88 of file TrackerRequest.cpp.

Protocols::BitTorrent::Trackers::TrackerRequest::TrackerRequest const Uri announceUrl,
const PeerInfo peerInfo,
const Torrent::InfoHash &  infoHash,
quint64  uploaded,
quint64  downloaded,
quint64  left,
bool  compact,
Event  event = Empty,
uint  numWant = 0,
QByteArray  key = QByteArray(),
QByteArray  trackerId = QByteArray()
 

TrackerRequest::~TrackerRequest  ) 
 

Destructor.

Destroys a TrackerRequest object.

Definition at line 78 of file TrackerRequest.cpp.


Member Function Documentation

Uri Protocols::BitTorrent::Trackers::TrackerRequest::announceUrl  )  const [inline]
 

Returns:
Announce URL of the tracker.

Definition at line 125 of file TrackerRequest.h.

bool Protocols::BitTorrent::Trackers::TrackerRequest::compact  )  const [inline]
 

Returns:
True if the peer is accepting a "compact" response format.

Definition at line 149 of file TrackerRequest.h.

quint64 Protocols::BitTorrent::Trackers::TrackerRequest::downloaded  )  const [inline]
 

Returns:
The total amount of downloaded bytes.

Definition at line 141 of file TrackerRequest.h.

TrackerRequest::Event Protocols::BitTorrent::Trackers::TrackerRequest::event  )  const [inline]
 

Returns:
Announcement event (reason).

Definition at line 153 of file TrackerRequest.h.

Torrent::InfoHash Protocols::BitTorrent::Trackers::TrackerRequest::infoHash  )  const [inline]
 

Returns:
Hash of the value of the info key.

Definition at line 133 of file TrackerRequest.h.

QByteArray Protocols::BitTorrent::Trackers::TrackerRequest::key  )  const [inline]
 

Returns:
An additional identification.

Definition at line 161 of file TrackerRequest.h.

quint64 Protocols::BitTorrent::Trackers::TrackerRequest::left  )  const [inline]
 

Returns:
The number of bytes to download.

Definition at line 145 of file TrackerRequest.h.

uint Protocols::BitTorrent::Trackers::TrackerRequest::numWant  )  const [inline]
 

Returns:
Number of peers to receive from the tracker.

Definition at line 157 of file TrackerRequest.h.

bool TrackerRequest::operator!= const TrackerRequest other  )  const
 

Inequality comparison.

Returns:
true if this object is not equal to the other object.

false otherwise.

Definition at line 129 of file TrackerRequest.cpp.

TrackerRequest & TrackerRequest::operator= const TrackerRequest other  ) 
 

Assignment operator.

Parameters:
other Object that will be assigned to this object.
Returns:
Reference to this object.

Definition at line 98 of file TrackerRequest.cpp.

bool TrackerRequest::operator== const TrackerRequest other  )  const
 

Equality comparison.

Returns:
true if this object is equal to the other object.

false otherwise.

Definition at line 109 of file TrackerRequest.cpp.

PeerInfo Protocols::BitTorrent::Trackers::TrackerRequest::peerInfo  )  const [inline]
 

Returns:
Peer info.

Definition at line 129 of file TrackerRequest.h.

QByteArray Protocols::BitTorrent::Trackers::TrackerRequest::trackerId  )  const [inline]
 

Returns:
Tracker ID.

Definition at line 165 of file TrackerRequest.h.

quint64 Protocols::BitTorrent::Trackers::TrackerRequest::uploaded  )  const [inline]
 

Returns:
The total amount of uploaded bytes.

Definition at line 137 of file TrackerRequest.h.


Member Data Documentation

QSharedDataPointer<PrivateData> Protocols::BitTorrent::Trackers::TrackerRequest::d [private]
 

Private data with implicit sharing.

Definition at line 121 of file TrackerRequest.h.


The documentation for this class was generated from the following files: