Detail::DownloadInfo Class Reference

DownloadInfo object controls downloading data from the remote client. More...

#include <clientext.h>

Inheritance diagram for Detail::DownloadInfo:

Detail::ClientExtBase List of all members.

Public Member Functions

 DownloadInfo (Client *parent, PartData *pd, PartMapPtr partMap)
 ~DownloadInfo ()
PartData * getReqPD () const
std::list< Range32 > getChunkReqs ()
 Generate three chunk requests to be downloaded from this client.
bool write (Range32 r, const std::string &data)
 Write data to the underlying temp file.
bool writePacked (uint32_t begin, uint32_t size, const std::string &data)
 Write packed data.

Static Public Member Functions

static size_t count ()
 Number of DownloadInfo objects alive.

Private Types

typedef std::list< LockedRangePtr
>::iterator 
Iter

Private Attributes

PartData * m_reqPD
 The chunks the remote party has of this file.
PartMapPtr m_partMap
UsedRangePtr m_curPart
 Current active <=9500kb part.
std::list< LockedRangePtr > m_reqChunks
 Currently locked up to 3 chunks.
std::string m_packedBuffer
 Internal buffer for packed data.
uint32_t m_packedBegin
 Begin offset for packed data.
uint32_t m_received
 How much data we have received during this download session.

Detailed Description

DownloadInfo object controls downloading data from the remote client.

It is driven by Client object, and instanciated when we can start downloading from the remote client. As such, it's purpose is to act as a layer between Client (which only performs basic packet handling), and actual data processing (which is handled by PartData class internally). This class is also responsible for generating chunk requests for asking from the remote client.

Definition at line 236 of file clientext.h.


Member Typedef Documentation

typedef std::list<LockedRangePtr>::iterator Detail::DownloadInfo::Iter [private]
 

Definition at line 282 of file clientext.h.


Constructor & Destructor Documentation

Detail::DownloadInfo::DownloadInfo Client parent,
PartData *  pd,
PartMapPtr  partMap
 

Definition at line 306 of file clientext.cpp.

References Detail::s_downloadInfoCnt.

Detail::DownloadInfo::~DownloadInfo  ) 
 

Definition at line 314 of file clientext.cpp.

References Client::getIpPort(), m_packedBegin, m_packedBuffer, m_received, m_reqChunks, m_reqPD, Detail::s_downloadInfoCnt, Detail::TRACE_CLIENT, and write().


Member Function Documentation

PartData* Detail::DownloadInfo::getReqPD  )  const [inline]
 

Definition at line 241 of file clientext.h.

References m_reqPD.

std::list< Range32 > Detail::DownloadInfo::getChunkReqs  ) 
 

Generate three chunk requests to be downloaded from this client.

Call this method AFTER selecting a part using selectPart() method.

Note that in ed2k network, chunk requests are used in overlapping manner, e.g. each next chunk request contains two previous ranges plus one new range, and a new chunk request is sent after each chunk is downloaded. This method takes care of these details, and returns three chunk requests ready to be sent out to the uploader.

Returns:
Up to three requested chunks of size <= 180kb each

Definition at line 345 of file clientext.cpp.

References ED2K_CHUNKSIZE, m_curPart, m_partMap, m_reqChunks, and m_reqPD.

bool Detail::DownloadInfo::write Range32  r,
const std::string &  data
 

Write data to the underlying temp file.

Parameters:
r Range to write to
data Data to be written
Returns:
True if chunk was completed, and getReqChunks() must be called again.

Definition at line 375 of file clientext.cpp.

References Detail::TRACE_CLIENT.

Referenced by ~DownloadInfo().

bool Detail::DownloadInfo::writePacked uint32_t  begin,
uint32_t  size,
const std::string &  data
 

Write packed data.

Parameters:
begin Begin offset of the packed data.
size Total size of packed data, e.g. at what point we consider the data buffer "complete".
data The data itself
Returns:
True if chunk was completed, and getReqChunks() must be called again.

Definition at line 410 of file clientext.cpp.

References Detail::TRACE_CLIENT.

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

Number of DownloadInfo objects alive.

Definition at line 341 of file clientext.cpp.

References Detail::s_downloadInfoCnt.


Member Data Documentation

PartData* Detail::DownloadInfo::m_reqPD [private]
 

The chunks the remote party has of this file.

Definition at line 284 of file clientext.h.

Referenced by getChunkReqs(), getReqPD(), and ~DownloadInfo().

PartMapPtr Detail::DownloadInfo::m_partMap [private]
 

Definition at line 287 of file clientext.h.

Referenced by getChunkReqs().

UsedRangePtr Detail::DownloadInfo::m_curPart [private]
 

Current active <=9500kb part.

Definition at line 289 of file clientext.h.

Referenced by getChunkReqs().

std::list<LockedRangePtr> Detail::DownloadInfo::m_reqChunks [private]
 

Currently locked up to 3 chunks.

Definition at line 292 of file clientext.h.

Referenced by getChunkReqs(), and ~DownloadInfo().

std::string Detail::DownloadInfo::m_packedBuffer [private]
 

Internal buffer for packed data.

Definition at line 294 of file clientext.h.

Referenced by ~DownloadInfo().

uint32_t Detail::DownloadInfo::m_packedBegin [private]
 

Begin offset for packed data.

Definition at line 295 of file clientext.h.

Referenced by ~DownloadInfo().

uint32_t Detail::DownloadInfo::m_received [private]
 

How much data we have received during this download session.

Definition at line 298 of file clientext.h.

Referenced by ~DownloadInfo().


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