eLynx SDK v3.3.0
C++ image processing API reference
Public Member Functions | Protected Member Functions

eLynx::ProgressNotifier Class Reference

Abstract progress notifier class. More...

#include <ProgressNotifier.h>

List of all members.

Public Member Functions

 ProgressNotifier (uint32 iPhases=1, float iSensitivity=0.01f)
 Constructor, creates progress notifier with given number of phases and sensitivity.
virtual ~ProgressNotifier ()
 Virtual destructor.
uint32 GetPhaseCount () const
 Returns the number of phases.
float GetSensitivity () const
 Returns progress sensitivity.
void SetSensitivity (float iSensitivity)
 Sets progress sensitivity.
float GetCurrentProgress () const
 Returns the progress of current phase as number in interval <0, 1>.
uint32 GetCurrentPhase () const
 Returns the number of current phase (zero-based).
void SetProgress (float iProgress, uint32 iPhase=0)
 Sets the current phase and progress.
void Log (const char *iprString, uint32 iPhase=0)
void PushCurrentPhase (bool ibIncrement)
 Pushes current phase into the stack to became new phase offset and (if required) increments it.
void PopCurrentPhase ()
 Removes the phase offset from the stack and increments current phase.
void RequestCancel ()
 Request operation cancel.
bool IsCanceled () const
 Returns true if caller requested operation to cancel itself.

Protected Member Functions

virtual void Notify (float iProgress, uint32 iPhase)
 that is called by SetProgress method.
virtual void Notify (const char *iprString, uint32 iPhase)

Detailed Description

Abstract progress notifier class.

This class is used by time-consuming operations to notify caller about operation progress. Also, it allows caller to request operation cancel. Progress is represented as floating point number in the interval <0, 1>. Class supports multiphase progress. Progress of each phase of the operation is in <0, 1> interval as well. Everytime the caller should be notified about the progress, virtual method NotifyProgress is invoked. It is invoked if the current phase has changed or if the difference in progress is bigger than progress sensitivity. Progress sensitivity prevents from unnecessary calls to NotifyProgress, which may be nontrivial operation. Default sensitivity is 0.01 (1%). Class also implements phase offset stack. This can be useful if the operation calls another time-consuming operation, which also requires progress notifier. It should push current phase offset and then it can pass progress notifier object to the subsequent operation. After it is finished, it should pop the offset and continue processing. This way, progress of subsequent operation will be "rendered" in the context of caller.


Constructor & Destructor Documentation

eLynx::ProgressNotifier::ProgressNotifier ( uint32  iPhases = 1,
float  iSensitivity = 0.01f 
)

Constructor, creates progress notifier with given number of phases and sensitivity.

Parameters:
iPhasesthe number of operation progress phases.
iSensitivitythe sensitivity of progress notification.

Member Function Documentation

uint32 eLynx::ProgressNotifier::GetCurrentPhase (  ) const

Returns the number of current phase (zero-based).

It is a number between 0 and GetPhaseCount()-1. Current phase offset (if any) is already included in this value.

Returns:
the number of current phase
float eLynx::ProgressNotifier::GetCurrentProgress (  ) const

Returns the progress of current phase as number in interval <0, 1>.

Returns:
the progress of current phase
uint32 eLynx::ProgressNotifier::GetPhaseCount (  ) const

Returns the number of phases.

This value is the same as specified in constructor. It is not affected by phase offset stack.

Returns:
the total number of phases
float eLynx::ProgressNotifier::GetSensitivity (  ) const

Returns progress sensitivity.

If the difference between actual and new progress is bigger than this value, NotifyProgress would be invoked.

Returns:
the progress sensitivity.
virtual void eLynx::ProgressNotifier::Notify ( float  iProgress,
uint32  iPhase 
) [protected, virtual]

that is called by SetProgress method.

This method should be redefined to perform appropriate actions (like updating progress bar control or writing info to the console).

Parameters:
iProgressthe progress of current phase in interval <0, 1>
iPhasethe number fo current phase
void eLynx::ProgressNotifier::PushCurrentPhase ( bool  ibIncrement )

Pushes current phase into the stack to became new phase offset and (if required) increments it.

Subsequent calls to SetProgress will increment phase number with this offset. Should be called before ProgressNotifier is passed to another operation, which also accepts ProgressNotifier. After that, PopCurrentPhase should be called to switch to next phase.

Parameters:
ibIncrementif true, current phase number is incremented before pushed into the stack. Should be false if subsequent operation is first operation at all. Otherwise, if true, it saves caller from necessity to update progress phase before passing notifier to subsequent call.
void eLynx::ProgressNotifier::RequestCancel (  )

Request operation cancel.

After calling this method, IsCanceled will start returning true. It is operation responsibility to check this method and return ASAP, if cancel is requested.

void eLynx::ProgressNotifier::SetProgress ( float  iProgress,
uint32  iPhase = 0 
)

Sets the current phase and progress.

The number of the phase is taken relative to the current phase offset (offset is added to the iPhase value). If the difference between actual and new progress is bigger than sensitivity, NotifyProgress is invoked.

void eLynx::ProgressNotifier::SetSensitivity ( float  iSensitivity )

Sets progress sensitivity.

If the difference between actual and new progress is bigger than this value, NotifyProgress would be invoked.

Returns:
the progress sensitivity.

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

Generated on Thu Dec 9 2010 by doxygen 1.7.2