API for reporting a single progress fraction from multiple hierarchical sources. More...
#include <mbl_progress_hierarchy.h>
Public Member Functions | |
void | set_estimated_iterations (const vcl_string &identifier, const int iterations, const vcl_string &display_text) |
Estimated number of iterations for the given identifier. | |
void | set_throw_exception_on_cancel (bool t) |
If true set_progress() will throw an exception if cancel has been set. | |
void | set_progress (const vcl_string &identifier, const int progress) |
Sets progress for the given identifier. | |
void | increment_progress (const vcl_string &identifier, const int n=1) |
Increments progress for the given identifier by n. | |
void | end_progress (const vcl_string &identifier) |
Explicitly marks the end of loop for the given identifier. | |
int | progress (const vcl_string &identifier) const |
Gets progress for given identifier. | |
vcl_string | display_text (const vcl_string &identifier) const |
Gets display text for given identifier. | |
int | estimated_iterations (const vcl_string &identifier) const |
Gets estimated total iterations for given identifier. | |
void | set_cancelled (const vcl_string &identifier, const bool cancel) |
Modify the flag to cancel the current process. | |
bool | is_cancelled (const vcl_string &identifier) const |
Check whether progress object is marked as cancelled. | |
Protected Member Functions | |
virtual void | on_set_estimated_iterations (const vcl_string &identifier, const int total_iterations) |
Called when set_estimate_iterations() is called for a given identifier. | |
virtual void | on_set_progress (const vcl_string &identifier, const int progress) |
Called when set_progress() is called for a given identifier. | |
virtual void | on_end_progress (const vcl_string &identifier) |
Called when end_progress() is called for a given identifier. | |
virtual void | on_changed_progress (double fraction)=0 |
Called when the progress has started, changed, or finished. | |
mbl_progress_hierarchy () | |
Private Attributes | |
vcl_vector< vcl_string > | identifier_stack_ |
The ordered hierarchy of identifiers. | |
bool | just_ended_ |
Has an existing identifier just been ended. |
API for reporting a single progress fraction from multiple hierarchical sources.
This progress class assumes that each identifier is arranged in a hierarchy, and that calls to set_estimated_iterations and end_progress are correctly nested.
In order to use this abstract you need to derive this class and provide a definition of on_changed_progress().
Definition at line 21 of file mbl_progress_hierarchy.h.
mbl_progress_hierarchy::mbl_progress_hierarchy | ( | ) | [inline, protected] |
Definition at line 49 of file mbl_progress_hierarchy.h.
vcl_string mbl_progress::display_text | ( | const vcl_string & | identifier | ) | const [inherited] |
Gets display text for given identifier.
identifier | to query. |
Definition at line 83 of file mbl_progress.cxx.
void mbl_progress::end_progress | ( | const vcl_string & | identifier | ) | [inherited] |
Explicitly marks the end of loop for the given identifier.
Definition at line 62 of file mbl_progress.cxx.
int mbl_progress::estimated_iterations | ( | const vcl_string & | identifier | ) | const [inherited] |
Gets estimated total iterations for given identifier.
identifier | to query. |
Definition at line 97 of file mbl_progress.cxx.
void mbl_progress::increment_progress | ( | const vcl_string & | identifier, |
const int | n = 1 |
||
) | [inherited] |
Increments progress for the given identifier by n.
Definition at line 48 of file mbl_progress.cxx.
bool mbl_progress::is_cancelled | ( | const vcl_string & | identifier | ) | const [inherited] |
Check whether progress object is marked as cancelled.
identifier | Progress object to check. |
Definition at line 130 of file mbl_progress.cxx.
virtual void mbl_progress_hierarchy::on_changed_progress | ( | double | fraction | ) | [protected, pure virtual] |
Called when the progress has started, changed, or finished.
fraction | Progress of all identifiers towards the end. value is out of 1.0. |
Implemented in mbl_progress_callback.
void mbl_progress_hierarchy::on_end_progress | ( | const vcl_string & | identifier | ) | [protected, virtual] |
Called when end_progress() is called for a given identifier.
Derived classes may take some action here.
identifier | The operation being monitored. |
Implements mbl_progress.
Definition at line 76 of file mbl_progress_hierarchy.cxx.
void mbl_progress_hierarchy::on_set_estimated_iterations | ( | const vcl_string & | identifier, |
const int | total_iterations | ||
) | [protected, virtual] |
Called when set_estimate_iterations() is called for a given identifier.
Derived classes may take some action here.
identifier | The operation being monitored. |
Implements mbl_progress.
Definition at line 24 of file mbl_progress_hierarchy.cxx.
void mbl_progress_hierarchy::on_set_progress | ( | const vcl_string & | identifier, |
const int | progress | ||
) | [protected, virtual] |
Called when set_progress() is called for a given identifier.
Derived classes may take some action here.
identifier | The operation being monitored. |
progress | The new progress status. |
Implements mbl_progress.
Definition at line 46 of file mbl_progress_hierarchy.cxx.
int mbl_progress::progress | ( | const vcl_string & | identifier | ) | const [inherited] |
Gets progress for given identifier.
identifier | to query. |
Definition at line 69 of file mbl_progress.cxx.
void mbl_progress::set_cancelled | ( | const vcl_string & | identifier, |
const bool | cancel | ||
) | [inherited] |
Modify the flag to cancel the current process.
identifier | Progress object to cancel. |
Definition at line 114 of file mbl_progress.cxx.
void mbl_progress::set_estimated_iterations | ( | const vcl_string & | identifier, |
const int | iterations, | ||
const vcl_string & | display_text | ||
) | [inherited] |
Estimated number of iterations for the given identifier.
Definition at line 11 of file mbl_progress.cxx.
void mbl_progress::set_progress | ( | const vcl_string & | identifier, |
const int | progress | ||
) | [inherited] |
Sets progress for the given identifier.
Checks whether cancel has been set; if so calls end_progress(), and throws an exception if "throw_exception_on_cancel" is true.
Definition at line 24 of file mbl_progress.cxx.
void mbl_progress::set_throw_exception_on_cancel | ( | bool | t | ) | [inline, inherited] |
If true set_progress() will throw an exception if cancel has been set.
Definition at line 64 of file mbl_progress.h.
vcl_vector<vcl_string> mbl_progress_hierarchy::identifier_stack_ [private] |
The ordered hierarchy of identifiers.
Definition at line 53 of file mbl_progress_hierarchy.h.
bool mbl_progress_hierarchy::just_ended_ [private] |
Has an existing identifier just been ended.
Definition at line 56 of file mbl_progress_hierarchy.h.