Cupt
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
cupt::download::Progress Class Reference

download progress meter More...

#include <cupt/download/progress.hpp>

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

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 More...
 
void setLongAliasForUri (const string &uri, const string &alias)
 sets a long alias for URI More...
 
void markAsOptional (const string &uri)
 
virtual ~Progress ()
 destructor
 

Static Public Attributes

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

Protected Member Functions

string getLongAliasForUri (const string &uri) const
 
string getShortAliasForUri (const string &uri) const
 
bool isOptional (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

Member Function Documentation

◆ finishedDownloadHook()

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.

◆ finishHook()

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

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

Reimplemented in cupt::download::ConsoleProgress.

◆ getDownloadRecords()

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

Gets current downloads.

Returns
map of uris to download records.

◆ getDownloadSpeed()

size_t cupt::download::Progress::getDownloadSpeed ( ) const
protected
Returns
current download speed in bytes/second

◆ getLongAliasForUri()

string cupt::download::Progress::getLongAliasForUri ( const string &  uri) const
protected
Parameters
uri
Returns
long alias for uri if it was specified, uri otherwise

◆ getOverallDownloadedSize()

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

◆ getOverallDownloadTime()

size_t cupt::download::Progress::getOverallDownloadTime ( ) const
protected
Returns
number of seconds since the start of the download session

◆ getOverallEstimatedSize()

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

◆ getOverallEstimatedTime()

size_t cupt::download::Progress::getOverallEstimatedTime ( ) const
protected
Returns
number of seconds, estimated time to finish since the start of the download session

◆ getOverallFetchedSize()

uint64_t cupt::download::Progress::getOverallFetchedSize ( ) const
protected
Returns
total byte count of all data chunks fetched from the network (or its equivalent)

◆ getShortAliasForUri()

string cupt::download::Progress::getShortAliasForUri ( const string &  uri) const
protected
Parameters
uri
Returns
short alias for uri if it was specified, uri otherwise

◆ isOptional()

bool cupt::download::Progress::isOptional ( const string &  uri) const
protected
See also
markAsOptional

◆ markAsOptional()

void cupt::download::Progress::markAsOptional ( const string &  uri)

Notify that a failure to download uri is not an error.

Parameters
uri

◆ newDownloadHook()

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.

◆ setLongAliasForUri()

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

sets a long alias for URI

Parameters
uri
aliaslong alias

◆ setShortAliasForUri()

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

sets a short alias for URI

Parameters
uri
aliasshort alias

◆ updateHook()

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

◆ speedCalculatingAccuracy

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: