BazisLib::Network::MultiThreaded::FileChunkDatabase Class Reference

Stores information about downloaded portions of a file. More...

#include <mtdl.h>

Collaboration diagram for BazisLib::Network::MultiThreaded::FileChunkDatabase:

Collaboration graph
[legend]

List of all members.

Classes

class  PendingChunk

Public Member Functions

 FileChunkDatabase (ULONGLONG FileSize)
bool OnFileChunkDownloaded (unsigned ChunkID, ULONGLONG Size)
void OnChunkDownloadStopped (unsigned ChunkID)
bool GetRangeToDownload (ULONGLONG *pOffset, ULONGLONG *pEndOffset, unsigned *pChunkID)
 Returns false ONLY if no more chunks are left to download.
ULONGLONG GetChunkEndOffset (unsigned ChunkID)
bool DownloadComplete ()
bool SaveToFileInNativeFormat (ManagedPointer< AIFile > file)
bool LoadFromFileInNativeFormat (ManagedPointer< AIFile > file)
bool Valid ()
void Reset (ULONGLONG FileSize)
void ResumeFile (ULONGLONG FileSize, ULONGLONG DownloadedSize)
ULONGLONG GetAlreadyDownloadedSize ()
 Returns the amount of data already downloaded.
bool CheckIntegrity ()
std::vector< PendingChunkExtractSortedPendingChunkList ()
std::vector< PendingChunkExtractSortedDoneChunkList ()

Private Types

enum  { MIN_CHUNK_SIZE_TO_RESUME = 32768 }

Private Attributes

RWLock m_ChunkListLock
SingleMallocVector< PendingChunkm_PendingChunks


Detailed Description

Stores information about downloaded portions of a file.

Remarks:
This class is completely thread-safe.
Attention:
The chunks are never deleted or embedded with others. That way, a thread, that loads a chunk, can always use its number to reference it.

Member Enumeration Documentation

anonymous enum [private]

Enumerator:
MIN_CHUNK_SIZE_TO_RESUME 


Constructor & Destructor Documentation

BazisLib::Network::MultiThreaded::FileChunkDatabase::FileChunkDatabase ( ULONGLONG  FileSize  ) 


Member Function Documentation

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::CheckIntegrity (  ) 

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::DownloadComplete (  ) 

std::vector<PendingChunk> BazisLib::Network::MultiThreaded::FileChunkDatabase::ExtractSortedDoneChunkList (  ) 

std::vector<PendingChunk> BazisLib::Network::MultiThreaded::FileChunkDatabase::ExtractSortedPendingChunkList (  ) 

ULONGLONG BazisLib::Network::MultiThreaded::FileChunkDatabase::GetAlreadyDownloadedSize (  ) 

Returns the amount of data already downloaded.

Attention:
This method is relatively slow, as it scans the whole database and calculates the downloaded data amount. Avoid calling it too frequently.

ULONGLONG BazisLib::Network::MultiThreaded::FileChunkDatabase::GetChunkEndOffset ( unsigned  ChunkID  ) 

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::GetRangeToDownload ( ULONGLONG pOffset,
ULONGLONG pEndOffset,
unsigned *  pChunkID 
)

Returns false ONLY if no more chunks are left to download.

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::LoadFromFileInNativeFormat ( ManagedPointer< AIFile file  ) 

void BazisLib::Network::MultiThreaded::FileChunkDatabase::OnChunkDownloadStopped ( unsigned  ChunkID  ) 

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::OnFileChunkDownloaded ( unsigned  ChunkID,
ULONGLONG  Size 
)

void BazisLib::Network::MultiThreaded::FileChunkDatabase::Reset ( ULONGLONG  FileSize  ) 

void BazisLib::Network::MultiThreaded::FileChunkDatabase::ResumeFile ( ULONGLONG  FileSize,
ULONGLONG  DownloadedSize 
)

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::SaveToFileInNativeFormat ( ManagedPointer< AIFile file  ) 

bool BazisLib::Network::MultiThreaded::FileChunkDatabase::Valid (  )  [inline]


Member Data Documentation


The documentation for this class was generated from the following file:
SourceForge.net Logo