Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
mbl_progress_callback Class Reference

Reports a single progress fraction to a C callback function. More...

#include <mbl_progress_callback.h>

Inheritance diagram for mbl_progress_callback:
Inheritance graph
[legend]

List of all members.

Public Types

typedef void(* callback_ptr_t )(double progress)

Public Member Functions

 mbl_progress_callback (callback_ptr_t func)
 Pass in callback function pointer on construction.
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_changed_progress (double fraction)
 Called when the progress has started, changed, or finished.
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.

Protected Attributes

callback_ptr_t func_

Detailed Description

Reports a single progress fraction to a C callback function.

This class assumes that each progress identifier is arranged in a hierarchy, and that calls to set_estimated_iterations and end_progress are correctly nested.

Definition at line 20 of file mbl_progress_callback.h.


Member Typedef Documentation

typedef void(* mbl_progress_callback::callback_ptr_t)(double progress)

Definition at line 23 of file mbl_progress_callback.h.


Constructor & Destructor Documentation

mbl_progress_callback::mbl_progress_callback ( callback_ptr_t  func) [inline]

Pass in callback function pointer on construction.

Definition at line 26 of file mbl_progress_callback.h.


Member Function Documentation

vcl_string mbl_progress::display_text ( const vcl_string &  identifier) const [inherited]

Gets display text for given identifier.

Parameters:
identifierto 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.

Parameters:
identifierto query.
Returns:
progress (-1 if identifier is not known by this object).

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.

Parameters:
identifierProgress object to check.
Returns:
True if a cancel flag is set for this progress object.

Definition at line 130 of file mbl_progress.cxx.

virtual void mbl_progress_callback::on_changed_progress ( double  fraction) [inline, protected, virtual]

Called when the progress has started, changed, or finished.

Parameters:
fractionProgress of all identifiers towards the end. value is out of 1.0.

Implements mbl_progress_hierarchy.

Definition at line 35 of file mbl_progress_callback.h.

void mbl_progress_hierarchy::on_end_progress ( const vcl_string &  identifier) [protected, virtual, inherited]

Called when end_progress() is called for a given identifier.

Derived classes may take some action here.

Parameters:
identifierThe 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, inherited]

Called when set_estimate_iterations() is called for a given identifier.

Derived classes may take some action here.

Parameters:
identifierThe 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, inherited]

Called when set_progress() is called for a given identifier.

Derived classes may take some action here.

Parameters:
identifierThe operation being monitored.
progressThe 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.

Parameters:
identifierto query.
Returns:
progress (-i if identifier is not known by this object).

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.

Parameters:
identifierProgress 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.


Member Data Documentation

Definition at line 30 of file mbl_progress_callback.h.


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