Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_http_helper_progress Class Reference

This holds information on the progress of a running HTTP transfer. More...

#include <ms_http_helper_progress.hpp>

Public Member Functions

 ms_http_helper_progress ()
 C++ STL collection support.
 
 ms_http_helper_progress (const ms_http_helper_progress &src)
 Copying constructor.
 
 ms_http_helper_progress (ms_http_helper_progress &parentProgress, double proportionOffset, UINT64 byteOffset, double scale)
 Initialise the object with a link to a parent progress reporter.
 
 ~ms_http_helper_progress ()
 Destructor.
 
void copyFrom (const ms_http_helper_progress *right)
 Copies all data from another instance of the class.
 
UINT64 getCurrentBytes () const
 Returns the number of bytes sent or received.
 
double getProportion () const
 Returns a number from 0 to 1.0 that indicates how far the transaction has progressed.
 
UINT64 getTotalBytes () const
 Returns the total number of bytes that are due to be sent or received, or zero if the number is unknown.
 
bool hasParent () const
 Returns true if progress proportion is being forwarded to a parent object.
 
bool isAbortSet () const
 Returns true if the transaction has been asked to abort.
 
bool isComplete () const
 Returns true if the transaction has run to completion (not terminated by error or abort).
 
bool isStarted () const
 Returns true if the transaction has started running.
 
void setAbort ()
 Cause the transaction to abort at the next available point.
 

Detailed Description

This holds information on the progress of a running HTTP transfer.

A progress object is passed to the connection when an extended transaction is started. The transaction updates the information as the transaction is going on.

Often, extended transactions are started on a worker thread so that other task (for example, the user interface) may continue to function while the transaction is in progress). An object of this class allows communication with the transaction while being processed on that thread.

This object can also be used to cancel the transaction prematurely if required.

Constructor & Destructor Documentation

◆ ms_http_helper_progress() [1/2]

C++ STL collection support.

STL collections, such as vector, need a default constructor.

◆ ms_http_helper_progress() [2/2]

ms_http_helper_progress ( ms_http_helper_progress parentProgress,
double  proportionOffset,
UINT64  byteOffset,
double  scale 
)

Initialise the object with a link to a parent progress reporter.

When the progress helper is linked to a parent progress helper, all setProgress() calls are forwarded to the parent. You need to specify the offset and scale. For example, if you have two tasks, then use scale=0.5 for child progress helper 1 and child progress helper 2; and use offset=0.0 for the first one and offset=0.5 for the second one.

Only the proportion and current bytes are forwarded to the parent. Task start, abort or completion are not forwarded.

Parameters
parentProgressAll setProgress() calls are forwarded to this parent. If null, nothing is forwarded.
proportionOffsetAn offset to add to forwarded proportion.
byteOffsetAn offset to add to forwarded current bytes.
scaleA scale by which the subtask proportion is multiplied.

Member Function Documentation

◆ getCurrentBytes()

UINT64 getCurrentBytes ( ) const

Returns the number of bytes sent or received.

This is the number of characters actually transferred so far.

Returns
The number of characters transferred so far.

◆ getProportion()

double getProportion ( ) const

Returns a number from 0 to 1.0 that indicates how far the transaction has progressed.

If the total amount to be transferred is unknown then the proportion value will change but does not represent any indication of the amount remaining.

Returns
The proportion of the task that has been completed. Zero if the amount is unknown.

◆ getTotalBytes()

UINT64 getTotalBytes ( ) const

Returns the total number of bytes that are due to be sent or received, or zero if the number is unknown.

This is the size (in characters) of the file to be transferred.

For a download, the number of characters that are going to be sent by the server is not usually known until after the transfer is complete. In this case, this number remains zero.

Returns
The number of characters to be transferred (including those already transferred).

◆ hasParent()

bool hasParent ( ) const

Returns true if progress proportion is being forwarded to a parent object.

Returns
True if the object was initialised with a parent progress link.

◆ isAbortSet()

bool isAbortSet ( ) const

Returns true if the transaction has been asked to abort.

This will return true after the setAbort() function has been called.

Returns
True if the task is to be aborted at user request (i.e. setAbort() has been called).

◆ isComplete()

bool isComplete ( ) const

Returns true if the transaction has run to completion (not terminated by error or abort).

If the transfer ended for any reason other than a successful transfer of all the data then this will continue to return false. The submit/download function will exit once the data transfer has ceased (for whatever reason).

Returns
True if the task has completed.

◆ isStarted()

bool isStarted ( ) const

Returns true if the transaction has started running.

Once the file transfer function has been called, there may be a delay before the transfer itself actually starts. This will only return true once the transfer of data has begun.

Returns
True if the task has started (i.e. setStarted() has been called).

◆ setAbort()

void setAbort ( )

Cause the transaction to abort at the next available point.

The file transfer, running on another thread, will continue until it gets to a suitable point and then exit.


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