Download Class Reference

Download is a wrapper class around ed2k-compatible PartData objects. More...

#include <downloadlist.h>

List of all members.


Public Member Functions

uint32_t getSourceCount () const
uint64_t getLastSrcExch () const
uint64_t getLastUdpQuery () const
PartData * getPartData () const
uint32_t getSourceLimit () const
Hash< ED2KHash > getHash () const
uint32_t getSize () const
void addSource (Client *c)
void delSource (Client *c)
void setSourceLimit (uint32_t l)
void setLastSrcExch (uint64_t t)
std::vector< SourcegetSources () const
 Generate a vector of sources, for sending with AnswerSources packet for example.
bool isSourceReqAllowed (Client *c) const
 Check if a client is allowed to request sources for this file at this time.

Private Types

typedef boost::tuple< uint32_t,
uint16_t, uint32_t, uint16_t > 
Source
 identical to AnswerSources::Source
typedef std::set< Client
* >::const_iterator 
CIter

Private Member Functions

 Download (PartData *pd, const Hash< ED2KHash > &hash)
 Construct new Download; this is allowed only by DownloadList.
 ~Download ()
 Destructor only allowed by DownloadList.
 Download (const Download &)
 Copy-construction is forbidden and not implemented.
Downloadoperator= (const Download &)
 Assignment operator is forbidden and not implemented.
void destroy ()
 Called prior to this object's destruction, signals all sources that download is being destroyed.

Private Attributes

PartData * m_partData
 Implementation object.
Hash< ED2KHash > m_hash
 hash of this file
std::set< Client * > m_sources
 list of sources of this file
uint64_t m_lastSrcExch
 time of last source-exchange req
uint32_t m_sourceLimit
 limit sources
uint64_t m_lastUdpQuery
 last udp query time

Friends

class DownloadList
bool operator< (const Download &x, const Download &y)

Detailed Description

Download is a wrapper class around ed2k-compatible PartData objects.

It keeps track of which clients are offering this file, providing means of getting an overview of sources-per-file and cross-reference. Download objects are owned and managed by DownloadList class.

Definition at line 50 of file downloadlist.h.


Member Typedef Documentation

typedef boost::tuple<uint32_t, uint16_t, uint32_t, uint16_t> Download::Source [private]
 

identical to AnswerSources::Source

Definition at line 52 of file downloadlist.h.

typedef std::set<Client*>::const_iterator Download::CIter [private]
 

Definition at line 53 of file downloadlist.h.


Constructor & Destructor Documentation

Download::Download PartData *  pd,
const Hash< ED2KHash > &  hash
[private]
 

Construct new Download; this is allowed only by DownloadList.

Parameters:
pd PartData object to wrap around
hash Hash of the PartData object

Definition at line 40 of file downloadlist.cpp.

Download::~Download  )  [private]
 

Destructor only allowed by DownloadList.

Definition at line 43 of file downloadlist.cpp.

Download::Download const Download  )  [private]
 

Copy-construction is forbidden and not implemented.


Member Function Documentation

uint32_t Download::getSourceCount  )  const [inline]
 

Definition at line 55 of file downloadlist.h.

References m_sources.

Referenced by isSourceReqAllowed(), Client::onPacket(), and Client::reaskForDownload().

uint64_t Download::getLastSrcExch  )  const [inline]
 

Definition at line 56 of file downloadlist.h.

References m_lastSrcExch.

uint64_t Download::getLastUdpQuery  )  const [inline]
 

Definition at line 57 of file downloadlist.h.

References m_lastUdpQuery.

PartData* Download::getPartData  )  const [inline]
 

Definition at line 58 of file downloadlist.h.

References m_partData.

Referenced by Detail::SourceInfo::checkNeedParts(), Client::onPacket(), Client::reaskForDownload(), Detail::SourceInfo::remOffered(), Client::reqDownload(), Detail::SourceInfo::setPartMap(), and Detail::SourceInfo::~SourceInfo().

uint32_t Download::getSourceLimit  )  const [inline]
 

Definition at line 59 of file downloadlist.h.

References m_sourceLimit.

Hash<ED2KHash> Download::getHash  )  const [inline]
 

Definition at line 60 of file downloadlist.h.

References m_hash.

Referenced by Client::onPacket(), Client::reaskForDownload(), Client::reqDownload(), and ServerList::udpGetSources().

uint32_t Download::getSize  )  const
 

Definition at line 98 of file downloadlist.cpp.

References m_partData.

Referenced by ServerList::udpGetSources().

void Download::addSource Client c  )  [inline]
 

Definition at line 63 of file downloadlist.h.

References m_sources.

Referenced by Detail::SourceInfo::addOffered().

void Download::delSource Client c  )  [inline]
 

Definition at line 64 of file downloadlist.h.

References m_sources.

Referenced by Detail::SourceInfo::remOffered().

void Download::setSourceLimit uint32_t  l  )  [inline]
 

Definition at line 65 of file downloadlist.h.

References m_sourceLimit.

void Download::setLastSrcExch uint64_t  t  )  [inline]
 

Definition at line 66 of file downloadlist.h.

References m_lastSrcExch.

Referenced by Client::onPacket().

std::vector< Download::Source > Download::getSources  )  const
 

Generate a vector of sources, for sending with AnswerSources packet for example.

Up to 500 sources may be returned.

Definition at line 85 of file downloadlist.cpp.

References m_sources.

Referenced by Client::onPacket().

bool Download::isSourceReqAllowed Client c  )  const
 

Check if a client is allowed to request sources for this file at this time.

Parameters:
c Client wishing to perform SourceExchange request
Returns:
True if request is allowed, false otherwise

Definition at line 45 of file downloadlist.cpp.

References getSourceCount(), m_lastSrcExch, m_sourceLimit, m_sources, SRCEXCH_CTIME, and SRCEXCH_FTIME.

Referenced by Client::onPacket().

Download& Download::operator= const Download  )  [private]
 

Assignment operator is forbidden and not implemented.

void Download::destroy  )  [private]
 

Called prior to this object's destruction, signals all sources that download is being destroyed.

Definition at line 100 of file downloadlist.cpp.

References m_sources.


Friends And Related Function Documentation

friend class DownloadList [friend]
 

Definition at line 84 of file downloadlist.h.

bool operator< const Download x,
const Download y
[friend]
 

Definition at line 85 of file downloadlist.h.


Member Data Documentation

PartData* Download::m_partData [private]
 

Implementation object.

Definition at line 111 of file downloadlist.h.

Referenced by getPartData(), and getSize().

Hash<ED2KHash> Download::m_hash [private]
 

hash of this file

Definition at line 112 of file downloadlist.h.

Referenced by getHash().

std::set<Client*> Download::m_sources [private]
 

list of sources of this file

Definition at line 113 of file downloadlist.h.

Referenced by addSource(), delSource(), destroy(), getSourceCount(), getSources(), and isSourceReqAllowed().

uint64_t Download::m_lastSrcExch [private]
 

time of last source-exchange req

Definition at line 114 of file downloadlist.h.

Referenced by getLastSrcExch(), isSourceReqAllowed(), and setLastSrcExch().

uint32_t Download::m_sourceLimit [private]
 

limit sources

Definition at line 115 of file downloadlist.h.

Referenced by getSourceLimit(), isSourceReqAllowed(), and setSourceLimit().

uint64_t Download::m_lastUdpQuery [private]
 

last udp query time

Definition at line 116 of file downloadlist.h.

Referenced by getLastUdpQuery().


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