eLynx SDK v3.0.1
C++ image processing API reference

eLynx::ProgressNotifier Class Reference

#include <ProgressNotifier.h>

List of all members.


Public Member Functions

 ProgressNotifier (uint32 iPhases=1, float iSensitivity=0.01f)
virtual ~ProgressNotifier ()
 Virtual destructor.
uint32 GetPhaseCount () const
float GetSensitivity () const
void SetSensitivity (float iSensitivity)
float GetCurrentProgress () const
uint32 GetCurrentPhase () const
void SetProgress (float iProgress, uint32 iPhase=0)
void Log (const char *iprString, uint32 iPhase=0)
void PushCurrentPhase (bool iIncrement)
void PopCurrentPhase ()
 Removes the phase offset from the stack and increments current phase.
void RequestCancel ()
bool IsCanceled () const
 Returns true if caller requested operation to cancel itself.

Protected Member Functions

virtual void Notify (float iProgress, uint32 iPhase)
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.

Definition at line 52 of file ProgressNotifier.h.


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:
iPhases the number of operation progress phases.
iSensitivity the sensitivity of progress notification.

virtual eLynx::ProgressNotifier::~ProgressNotifier (  )  [virtual]

Virtual destructor.


Member Function Documentation

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.

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.

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::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

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::Log ( const char *  iprString,
uint32  iPhase = 0 
)

void eLynx::ProgressNotifier::PushCurrentPhase ( bool  iIncrement  ) 

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:
iIncrement if 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::PopCurrentPhase (  ) 

Removes the phase offset from the stack and increments current phase.

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.

bool eLynx::ProgressNotifier::IsCanceled (  )  const [inline]

Returns true if caller requested operation to cancel itself.

Definition at line 118 of file ProgressNotifier.h.

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:
iProgress the progress of current phase in interval <0, 1>
iPhase the number fo current phase

virtual void eLynx::ProgressNotifier::Notify ( const char *  iprString,
uint32  iPhase 
) [protected, virtual]


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

Generated on 14 Apr 2009 by doxygen 1.5.8