PrevUpHomeNext

ProgressIndicator

struct ProgressIndicator
{
    function<void(int)> callback;
    size_t              granularity;
};

This structure is used to allow time-consuming API function calls to indicate their progress.

The structure consists of a callback, which can be any function or function object that is callable with an integer argument, and an integer granularity. The function should interpret its integer argument as an indication of progress as a fraction of the granularity. So for example, if the granularity is 1000, a time-consuming API function may call the callback with an integer argument of 800 to indicate that 80% of the task is complete.

The purpose of the granularity is to allow clients to control how often the API function calls the callback to update the progress. If the callback function is time-consuming and should not be run too often, the granularity can be decreased accordingly. On the other hand, if the callback function is quick and frequent progress reports are desired (e.g. for a high-resolution GUI progress bar), the granularity can be increasing accordingly. The API function is guaranteed not to call the callback more than 'granularity' times. (It may call the callback fewer than 'granularity' times if its own internal granularity of subtasks is not high enough).

The API functions that are potentially time-consuming are GenerateTimetables(), SortTimetables(), UpdateTimetableData(), and LoadTimetableData(). Other API functions are always fast and thus do not require progress indication.


PrevUpHomeNext