Cupt
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions
cupt::download::Progress Class Reference

download progress meter More...

#include <cupt/download/progress.hpp>

Inheritance diagram for cupt::download::Progress:
cupt::download::ConsoleProgress

List of all members.

Classes

struct  DownloadRecord
 download element More...

Public Member Functions

 Progress ()
 constructor
void setShortAliasForUri (const string &uri, const string &alias)
 sets a short alias for URI
void setLongAliasForUri (const string &uri, const string &alias)
 sets a long alias for URI
void setTotalEstimatedSize (uint64_t size)
 sets total download size for the all download progress lifetime
virtual ~Progress ()

Static Public Attributes

static float speedCalculatingAccuracy
 amount of seconds considered while calculating a download speed

Protected Member Functions

string getLongAliasForUri (const string &uri) const
string getShortAliasForUri (const string &uri) const
const std::map< string,
DownloadRecord > & 
getDownloadRecords () const
uint64_t getOverallDownloadedSize () const
uint64_t getOverallEstimatedSize () const
uint64_t getOverallFetchedSize () const
size_t getOverallDownloadTime () const
size_t getOverallEstimatedTime () const
size_t getDownloadSpeed () const
virtual void newDownloadHook (const string &uri, const DownloadRecord &downloadRecord)
virtual void finishedDownloadHook (const string &uri, const string &result)
virtual void updateHook (bool immediate)
virtual void finishHook ()

Detailed Description

download progress meter


Constructor & Destructor Documentation

virtual cupt::download::Progress::~Progress ( )
virtual

destructor


Member Function Documentation

virtual void cupt::download::Progress::finishedDownloadHook ( const string &  uri,
const string &  result 
)
protectedvirtual

This hook is called when some download is finished.

Parameters:
uri
resultdownload exit code, empty string is success, non-empty string is human-readable download error message

Reimplemented in cupt::download::ConsoleProgress.

virtual void cupt::download::Progress::finishHook ( )
protectedvirtual

This hook is called before the end of the download session.

Reimplemented in cupt::download::ConsoleProgress.

const std::map< string, DownloadRecord >& cupt::download::Progress::getDownloadRecords ( ) const
protected

Gets current downloads.

Returns:
map of uris to download records.
size_t cupt::download::Progress::getDownloadSpeed ( ) const
protected
Returns:
current download speed in bytes/second
string cupt::download::Progress::getLongAliasForUri ( const string &  uri) const
protected
Parameters:
uri
Returns:
long alias for uri if it was specified, uri otherwise
uint64_t cupt::download::Progress::getOverallDownloadedSize ( ) const
protected
Returns:
the sum of already done downloads in the current session plus the sum of downloaded parts of running downloads
size_t cupt::download::Progress::getOverallDownloadTime ( ) const
protected
Returns:
number of seconds since the start of the download session
uint64_t cupt::download::Progress::getOverallEstimatedSize ( ) const
protected

Overall estimated size is guaranteed to be not less than getOverallDownloadedSize.

Returns:
total estimated size counting both done and running downloads, and predefined size if it was set by setTotalEstimatedSize before
size_t cupt::download::Progress::getOverallEstimatedTime ( ) const
protected
Returns:
number of seconds, estimated time to finish since the start of the download session
uint64_t cupt::download::Progress::getOverallFetchedSize ( ) const
protected
Returns:
total byte count of all data chunks fetched from the network (or its equivalent)
string cupt::download::Progress::getShortAliasForUri ( const string &  uri) const
protected
Parameters:
uri
Returns:
short alias for uri if it was specified, uri otherwise
virtual void cupt::download::Progress::newDownloadHook ( const string &  uri,
const DownloadRecord downloadRecord 
)
protectedvirtual

This hook is called when new download starts.

Parameters:
uri
downloadRecord

Reimplemented in cupt::download::ConsoleProgress.

void cupt::download::Progress::setLongAliasForUri ( const string &  uri,
const string &  alias 
)

sets a long alias for URI

Parameters:
uri
aliaslong alias
void cupt::download::Progress::setShortAliasForUri ( const string &  uri,
const string &  alias 
)

sets a short alias for URI

Parameters:
uri
aliasshort alias
void cupt::download::Progress::setTotalEstimatedSize ( uint64_t  size)

sets total download size for the all download progress lifetime

This method should be called if this amount is known beforehand to get better overall progress indication.

Parameters:
sizenumber of bytes
virtual void cupt::download::Progress::updateHook ( bool  immediate)
protectedvirtual

This hook is called whenever some download information is updated (including being called after newDownloadHook and finishedDownloadHook).

Parameters:
immediateis update important or not; examples of important updates: new download, finished download, changes of a download state; examples of unimportant updates: number of download bytes changes for some download

Reimplemented in cupt::download::ConsoleProgress.


Member Data Documentation

float cupt::download::Progress::speedCalculatingAccuracy
static

amount of seconds considered while calculating a download speed

Default: 16


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