Detail::SourceInfo Class Reference

SourceInfo indicates a client which has one (or more) files to offer to us. More...

#include <clientext.h>

Inheritance diagram for Detail::SourceInfo:

Detail::ClientExtBase List of all members.

Public Member Functions

 SourceInfo (Client *parent, Download *file)
 Construct new SourceInfo object.
 ~SourceInfo ()
 Destructor; disconnects m_sig if connected.
Generic accessors
uint32_t getOffCount () const
DownloadgetReqFile () const
PartMapPtr getPartMap () const
uint32_t getQR () const
bool hasNeededParts () const
bool isFullSource () const
uint64_t getLastSrcExch () const
void setQR (uint32_t qr)
void setPartMap (const std::vector< bool > &pm)
void setReqFile (Download *file)
void addOffered (Download *file)
void remOffered (Download *file, bool cleanUp=true)
 Remove an offered file from this source.
bool offers (Download *file) const
 true if *this offers file

Static Public Member Functions

static size_t count ()
 Number of SourceInfo objects alive.

Private Member Functions

void checkNeedParts ()
 Checks if we need parts from this client, and sets m_needParts variable accordingly.

Private Attributes

std::set< Download * > m_offered
 Offered files.
Downloadm_reqFile
 Currently requested file.
PartMapPtr m_partMap
 Chunks the client has.
uint32_t m_qr
 Queue rank; Note: QR 0 == QueueFull.
bool m_needParts
 If we need smth.
uint64_t m_lastSrcExch
 Last time we did SourceExchange.

Detailed Description

SourceInfo indicates a client which has one (or more) files to offer to us.

SourceInfo object remains alive until the client has some files to offer us, e.g. until m_offered set size drops to zero. SourceInfo object may co-exist with DownloadInfo object in same Client object.

Definition at line 308 of file clientext.h.


Constructor & Destructor Documentation

Detail::SourceInfo::SourceInfo Client parent,
Download file
 

Construct new SourceInfo object.

Parameters:
parent Parent Client object
file The file this client offers

Definition at line 191 of file clientext.cpp.

References addOffered(), and Detail::s_sourceInfoCnt.

Detail::SourceInfo::~SourceInfo  ) 
 

Destructor; disconnects m_sig if connected.

Definition at line 197 of file clientext.cpp.

References Client::getIpPort(), Download::getPartData(), m_offered, m_partMap, m_reqFile, and Detail::s_sourceInfoCnt.


Member Function Documentation

uint32_t Detail::SourceInfo::getOffCount  )  const [inline]
 

Definition at line 325 of file clientext.h.

References m_offered.

Download* Detail::SourceInfo::getReqFile  )  const [inline]
 

Definition at line 326 of file clientext.h.

References m_reqFile.

PartMapPtr Detail::SourceInfo::getPartMap  )  const [inline]
 

Definition at line 327 of file clientext.h.

References m_partMap.

uint32_t Detail::SourceInfo::getQR  )  const [inline]
 

Definition at line 328 of file clientext.h.

References m_qr.

bool Detail::SourceInfo::hasNeededParts  )  const [inline]
 

Definition at line 329 of file clientext.h.

References m_needParts.

bool Detail::SourceInfo::isFullSource  )  const [inline]
 

Definition at line 330 of file clientext.h.

References m_partMap.

uint64_t Detail::SourceInfo::getLastSrcExch  )  const [inline]
 

Definition at line 331 of file clientext.h.

References m_lastSrcExch.

void Detail::SourceInfo::setQR uint32_t  qr  )  [inline]
 

Definition at line 333 of file clientext.h.

References m_qr.

void Detail::SourceInfo::setPartMap const std::vector< bool > &  pm  ) 
 

Definition at line 223 of file clientext.cpp.

References checkNeedParts(), Download::getPartData(), m_partMap, and m_reqFile.

void Detail::SourceInfo::setReqFile Download file  ) 
 

Definition at line 236 of file clientext.cpp.

References checkNeedParts(), and m_reqFile.

Referenced by addOffered(), and remOffered().

void Detail::SourceInfo::addOffered Download file  ) 
 

Definition at line 241 of file clientext.cpp.

References Download::addSource(), m_offered, m_reqFile, and setReqFile().

Referenced by SourceInfo().

void Detail::SourceInfo::remOffered Download file,
bool  cleanUp = true
 

Remove an offered file from this source.

Parameters:
file File this source is no longer offering
cleanUp If true, also clean up our stuff from PartData

Definition at line 251 of file clientext.cpp.

References Download::delSource(), Client::getIpPort(), Download::getPartData(), m_needParts, m_offered, m_partMap, m_reqFile, setReqFile(), and Detail::TRACE_CLIENT.

bool Detail::SourceInfo::offers Download file  )  const [inline]
 

true if *this offers file

Definition at line 347 of file clientext.h.

References m_offered.

size_t Detail::SourceInfo::count  )  [static]
 

Number of SourceInfo objects alive.

Definition at line 219 of file clientext.cpp.

References Detail::s_sourceInfoCnt.

Referenced by ClientList::checkOpenMoreSlots().

void Detail::SourceInfo::checkNeedParts  )  [private]
 

Checks if we need parts from this client, and sets m_needParts variable accordingly.

Assumes m_pm contains the remote client's offered parts map.

Definition at line 287 of file clientext.cpp.

References Download::getPartData(), m_needParts, m_partMap, and m_reqFile.

Referenced by setPartMap(), and setReqFile().


Member Data Documentation

std::set<Download*> Detail::SourceInfo::m_offered [private]
 

Offered files.

Definition at line 362 of file clientext.h.

Referenced by addOffered(), getOffCount(), offers(), remOffered(), and ~SourceInfo().

Download* Detail::SourceInfo::m_reqFile [private]
 

Currently requested file.

Definition at line 363 of file clientext.h.

Referenced by addOffered(), checkNeedParts(), getReqFile(), remOffered(), setPartMap(), setReqFile(), and ~SourceInfo().

PartMapPtr Detail::SourceInfo::m_partMap [private]
 

Chunks the client has.

Definition at line 364 of file clientext.h.

Referenced by checkNeedParts(), getPartMap(), isFullSource(), remOffered(), setPartMap(), and ~SourceInfo().

uint32_t Detail::SourceInfo::m_qr [private]
 

Queue rank; Note: QR 0 == QueueFull.

Definition at line 365 of file clientext.h.

Referenced by getQR(), and setQR().

bool Detail::SourceInfo::m_needParts [private]
 

If we need smth.

Definition at line 366 of file clientext.h.

Referenced by checkNeedParts(), hasNeededParts(), and remOffered().

uint64_t Detail::SourceInfo::m_lastSrcExch [private]
 

Last time we did SourceExchange.

Definition at line 367 of file clientext.h.

Referenced by getLastSrcExch().


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