Protocols::BitTorrent::Trackers::TrackerResponse Class Reference

#include <TrackerResponse.h> [code]

List of all members.


Detailed Description

Represents parsed tracker response.

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

Response structure is made according to this specification: http://wiki.theory.org/BitTorrentSpecification#Tracker_Response .

If the return value of failureReason() member function is not empty, then the original request to the tracker failed. If so, other getters will return default (e.g. empty) values. If there were no problem, failureReason() would return an empty string and other member functions would return values that were specified in the response, but only if the response was valid and was parsed correctly! See TrackerResponseParser for more details about parsing.

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 TrackerResponse object will be left in an unchanged state. Thus the class meets the strong guarantee of exception safety.

Note:
TrackerResponse objects (containing non-default data) can be created only using TrackerResponseParser which makes sure that only valid TrackerResponse objects are created.

Definition at line 61 of file TrackerResponse.h.

Public Types

typedef QList< PeerInfoPeerInfoList
 List of information about peers.

Public Member Functions

 TrackerResponse (const TrackerResponse &)
 Copy constructor.
TrackerResponseoperator= (const TrackerResponse &)
 Assignment operator.
bool operator== (const TrackerResponse &) const
 Equality comparison.
bool operator!= (const TrackerResponse &) const
 Inequality comparison.
 TrackerResponse ()
 Default constructor.
 ~TrackerResponse ()
 Destructor.
QString failureReason () const
QString warningMessage () const
uint interval () const
uint minInterval () const
QByteArray trackerId () const
uint complete () const
uint incomplete () const
PeerInfoList peers () const

Private Attributes

QSharedDataPointer< PrivateDatad
 Private data with implicit sharing.

Friends

class TrackerResponseParser

Classes

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


Member Typedef Documentation

typedef QList<PeerInfo> Protocols::BitTorrent::Trackers::TrackerResponse::PeerInfoList
 

List of information about peers.

Definition at line 68 of file TrackerResponse.h.


Constructor & Destructor Documentation

TrackerResponse::TrackerResponse const TrackerResponse 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 54 of file TrackerResponse.cpp.

TrackerResponse::TrackerResponse  ) 
 

Default constructor.

Constructs an empty TrackerResponse object.

Definition at line 31 of file TrackerResponse.cpp.

TrackerResponse::~TrackerResponse  ) 
 

Destructor.

Destroys a TrackerResponse object.

Definition at line 44 of file TrackerResponse.cpp.


Member Function Documentation

uint Protocols::BitTorrent::Trackers::TrackerResponse::complete  )  const [inline]
 

Returns:
Number of peers with the entire file, i.e. seeders.

Definition at line 133 of file TrackerResponse.h.

QString Protocols::BitTorrent::Trackers::TrackerResponse::failureReason  )  const [inline]
 

Return value will be non-empty only if the original request to the tracker failed. See class description for more info.

Definition at line 109 of file TrackerResponse.h.

uint Protocols::BitTorrent::Trackers::TrackerResponse::incomplete  )  const [inline]
 

Returns:
Number of non-seeder peers, aka "leechers".

Definition at line 137 of file TrackerResponse.h.

uint Protocols::BitTorrent::Trackers::TrackerResponse::interval  )  const [inline]
 

Returns:
Pause (in seconds) between requests sendings.

Definition at line 121 of file TrackerResponse.h.

uint Protocols::BitTorrent::Trackers::TrackerResponse::minInterval  )  const [inline]
 

Returns:
Minimum announce interval.

Definition at line 125 of file TrackerResponse.h.

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

Inequality comparison.

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

false otherwise.

Definition at line 94 of file TrackerResponse.cpp.

TrackerResponse & TrackerResponse::operator= const TrackerResponse other  ) 
 

Assignment operator.

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

Definition at line 64 of file TrackerResponse.cpp.

bool TrackerResponse::operator== const TrackerResponse other  )  const
 

Equality comparison.

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

false otherwise.

Definition at line 76 of file TrackerResponse.cpp.

TrackerResponse::PeerInfoList Protocols::BitTorrent::Trackers::TrackerResponse::peers  )  const [inline]
 

Returns:
List of information about peers.

Definition at line 141 of file TrackerResponse.h.

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

Returns:
Tracker ID.

Definition at line 129 of file TrackerResponse.h.

QString Protocols::BitTorrent::Trackers::TrackerResponse::warningMessage  )  const [inline]
 

This is similar to failure reason, but the response still got processed normally, so other data are present.

Definition at line 117 of file TrackerResponse.h.


Friends And Related Function Documentation

friend class TrackerResponseParser [friend]
 

Definition at line 86 of file TrackerResponse.h.


Member Data Documentation

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

Private data with implicit sharing.

Definition at line 101 of file TrackerResponse.h.


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