Detail::UploadInfo Class Reference

UploadInfo object is a part of Client object that represents the upload state. More...

#include <clientext.h>

Inheritance diagram for Detail::UploadInfo:

Detail::ClientExtBase List of all members.

Public Member Functions

 UploadInfo (Client *parent, QueueInfoPtr nfo)
 ~UploadInfo ()
void bufferData ()
 Reads first chunk in m_reqChunks into m_buffer from disk.
bool compress ()
 Attempts to compress the current m_buffer.
boost::tuple< uint32_t, uint32_t,
std::string > 
getNext (uint32_t amount)
 Get next data chunk from m_buffer.
Accessors for public usage
SharedFile * getReqFile () const
Hash< ED2KHash > getReqHash () const
uint32_t getSent () const
bool isCompressed () const
bool hasBuffered () const
uint8_t getReqChunkCount () const
void setReqFile (SharedFile *sf)
void setReqHash (const Hash< ED2KHash > &h)
void addReqChunk (Range32 r)

Static Public Member Functions

static size_t count ()
 Number of UploadInfo objects alive.

Private Attributes

SharedFile * m_reqFile
 Requested file.
Hash< ED2KHash > m_reqHash
 The hash of the requested file.
std::list< Range32 > m_reqChunks
 Requested ranges.
std::string m_buffer
 Data to be sent to this client, buffered.
uint32_t m_curPos
 If the client is uploading, this is the current uploading position.
uint32_t m_endPos
 End position of current buffered data.
bool m_compressed
 Whether current buffer is compressed or not.
uint32_t m_sent
 How much data (excluding overhead) have we sent to this client during this session.

Detailed Description

UploadInfo object is a part of Client object that represents the upload state.

Each uploading client is required to have this object as member. This object contains all the information needed to perform actual uploading to the remote client, e.g. data buffers et al.

Definition at line 59 of file clientext.h.


Constructor & Destructor Documentation

Detail::UploadInfo::UploadInfo Client parent,
QueueInfoPtr  nfo
 

Definition at line 76 of file clientext.cpp.

References m_reqFile, m_reqHash, and Detail::s_uploadInfoCnt.

Detail::UploadInfo::~UploadInfo  ) 
 

Definition at line 87 of file clientext.cpp.

References Client::getIpPort(), m_sent, Detail::s_uploadInfoCnt, and Detail::TRACE_CLIENT.


Member Function Documentation

SharedFile* Detail::UploadInfo::getReqFile  )  const [inline]
 

Definition at line 68 of file clientext.h.

References m_reqFile.

Hash<ED2KHash> Detail::UploadInfo::getReqHash  )  const [inline]
 

Definition at line 69 of file clientext.h.

References m_reqHash.

uint32_t Detail::UploadInfo::getSent  )  const [inline]
 

Definition at line 70 of file clientext.h.

References m_sent.

bool Detail::UploadInfo::isCompressed  )  const [inline]
 

Definition at line 71 of file clientext.h.

References m_compressed.

bool Detail::UploadInfo::hasBuffered  )  const [inline]
 

Definition at line 72 of file clientext.h.

References m_buffer.

uint8_t Detail::UploadInfo::getReqChunkCount  )  const [inline]
 

Definition at line 73 of file clientext.h.

References m_reqChunks.

void Detail::UploadInfo::setReqFile SharedFile *  sf  )  [inline]
 

Definition at line 75 of file clientext.h.

References m_reqFile.

void Detail::UploadInfo::setReqHash const Hash< ED2KHash > &  h  )  [inline]
 

Definition at line 76 of file clientext.h.

References m_reqHash.

void Detail::UploadInfo::addReqChunk Range32  r  ) 
 

Definition at line 169 of file clientext.cpp.

References m_reqChunks, m_sent, Detail::SEND_TO_ONE_CLIENT, and Detail::TRACE_CLIENT.

void Detail::UploadInfo::bufferData  ) 
 

Reads first chunk in m_reqChunks into m_buffer from disk.

Definition at line 100 of file clientext.cpp.

References Client::getIpPort(), m_buffer, m_curPos, m_endPos, m_reqChunks, m_reqFile, and Detail::TRACE_CLIENT.

bool Detail::UploadInfo::compress  ) 
 

Attempts to compress the current m_buffer.

Returns:
true if compression succeeded, false otherwise

Definition at line 116 of file clientext.cpp.

References Zlib::compress(), m_buffer, m_compressed, m_endPos, and Detail::TRACE_CLIENT.

boost::tuple< uint32_t, uint32_t, std::string > Detail::UploadInfo::getNext uint32_t  amount  ) 
 

Get next data chunk from m_buffer.

The requested data is deleted from buffer.

Parameters:
amount Amount of data to retrieve
Returns:
Three values, where first integer is the begin offset of the data, second value is either end offset (in case of uncompressed data), or the size of total compressed chunk, and string containing the actual data.
Note:
This function may return less data than requested if there was not enough data in m_buffer.

Definition at line 136 of file clientext.cpp.

References m_buffer, m_compressed, m_curPos, m_reqChunks, and m_sent.

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

Number of UploadInfo objects alive.

Definition at line 95 of file clientext.cpp.

References Detail::s_uploadInfoCnt.


Member Data Documentation

SharedFile* Detail::UploadInfo::m_reqFile [private]
 

Requested file.

Definition at line 112 of file clientext.h.

Referenced by bufferData(), getReqFile(), setReqFile(), and UploadInfo().

Hash<ED2KHash> Detail::UploadInfo::m_reqHash [private]
 

The hash of the requested file.

Definition at line 115 of file clientext.h.

Referenced by getReqHash(), setReqHash(), and UploadInfo().

std::list<Range32> Detail::UploadInfo::m_reqChunks [private]
 

Requested ranges.

Definition at line 118 of file clientext.h.

Referenced by addReqChunk(), bufferData(), getNext(), and getReqChunkCount().

std::string Detail::UploadInfo::m_buffer [private]
 

Data to be sent to this client, buffered.

This data may be compressed if the remote client supports compression. Also, the size of this buffer may be up to 180k when upload has just started, so this is quite memory-heavy.

Definition at line 126 of file clientext.h.

Referenced by bufferData(), compress(), getNext(), and hasBuffered().

uint32_t Detail::UploadInfo::m_curPos [private]
 

If the client is uploading, this is the current uploading position.

Definition at line 131 of file clientext.h.

Referenced by bufferData(), and getNext().

uint32_t Detail::UploadInfo::m_endPos [private]
 

End position of current buffered data.

Notice that this may instead indicate the size of compressed chunk, instead of the end offset, if the buffer is compressed. This because of eMule extended protocol system, refer to Packets::PackedChunk packet implementation for more information.

Definition at line 140 of file clientext.h.

Referenced by bufferData(), and compress().

bool Detail::UploadInfo::m_compressed [private]
 

Whether current buffer is compressed or not.

Definition at line 145 of file clientext.h.

Referenced by compress(), getNext(), and isCompressed().

uint32_t Detail::UploadInfo::m_sent [private]
 

How much data (excluding overhead) have we sent to this client during this session.

We should send 9.28mb to every client and then terminate the uploading so others can also get data.

This counter thus starts at 0, updated at every getNext() call, and if reaches 9.28mb, the object should be destroyed.

Definition at line 155 of file clientext.h.

Referenced by addReqChunk(), getNext(), getSent(), and ~UploadInfo().


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