class::sys::ProgressCallback

class sys::ProgressCallback
  : public api::InfoObject

The ProgressCallback class is used by various methods to allow the application to update the progress of an operation.

#include <sapi/sys.hpp>
#include <sapi/inet.hpp>
Printer p;

p.set_progress_key("downloading");
HttpClient http_client;
DataFile data_file(File::APPEND);

//download file to data_file and print the progress using #'s
http_client.get("http://some.url/file", data_file, p.progress_callback());

Summary

ProgressCallback()

ProgressCallback(

callback_t callback,
void * context
)

void set_callback(

bool(*)(void *, int, int) callback
)

void set_context(

void * context
)

bool update(

int value,
int total
) const

static int indeterminate_progress_total()

static int update_function(

const void * context,
int value,
int total
)

typedef bool(* callback_t

Members

ProgressCallback()

Constructs an empty object.


ProgressCallback(

callback_t callback,
void * context
)

Constructs a fully initialized callback.

Parameters

  • callback The function to execute

  • context The context (first argument passed to callback)


void set_callback(

bool(*)(void *, int, int) callback
)

Assigns a callback.


void set_context(

void * context
)

Assigns a context.


bool update(

int value,
int total
) const

Executes the callback if it is valid.

This method is called within operations in order to execute the provided callback.

Parameters

  • value The value of the progress of the operation

  • total The total possible progress for the operation

Returns

true to abort the operation or false to continue as normal


static int indeterminate_progress_total()

static int update_function(

const void * context,
int value,
int total
)


typedef bool(* callback_t

Defines the callback function prototype.

The function has three arguments. The first is the context() member of this object. The first integer is the current progress value and the second is the total progress value.

If the total (third argument) is zero, the operation is either complete or aborted. If total is set to -1, the progress should be shown as indeterminate.


X

Thanks for Coming!

Subscribe to news and updates