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. | |
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.
C++ STL collection support.
STL collections, such as vector, need a default 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.
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.
parentProgress | All setProgress() calls are forwarded to this parent. If null, nothing is forwarded. |
proportionOffset | An offset to add to forwarded proportion. |
byteOffset | An offset to add to forwarded current bytes. |
scale | A scale by which the subtask proportion is multiplied. |
UINT64 getCurrentBytes | ( | ) | const |
Returns the number of bytes sent or received.
This is the number of characters actually transferred so far.
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.
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.
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.
This will return true after the setAbort() function has been called.
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).
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.
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.