Plasma Engine  2.0
Loading...
Searching...
No Matches
plProgressRange Class Reference

plProgressRange is the preferred method to inform the system of progress. More...

#include <Progress.h>

Public Member Functions

 plProgressRange (plStringView sDisplayText, plUInt32 uiSteps, bool bAllowCancel, plProgress *pProgressbar=nullptr)
 Creates a progress range scope.
 
 plProgressRange (plStringView sDisplayText, bool bAllowCancel, plProgress *pProgressbar=nullptr)
 Creates a progress range scope without steps. Use SetCompletion to manually set the completion value.
 
 ~plProgressRange ()
 The destructor closes the current range. All progress in this range is assumed to have completed, even if BeginNextStep() has not been called once for every subdivision step.
 
plProgressGetProgressbar () const
 Returns the plProgress instance that this range uses.
 
void SetStepWeighting (plUInt32 uiStep, float fWeight)
 Allows to weigh each step differently.
 
bool BeginNextStep (plStringView sStepDisplayText, plUInt32 uiNumSteps=1)
 Should be called whenever a new sub-step is started to advance the progress.
 
bool SetCompletion (double fCompletionFactor)
 Manually set the completion value between 0..1.
 
bool WasCanceled () const
 Whether the user requested to cancel the operation.
 

Friends

class plProgress
 

Detailed Description

plProgressRange is the preferred method to inform the system of progress.

plProgressRange is a scoped class, ie. upon creation it adds a range to the current progress and upon destruction the entire range is considered to be completed. Ranges can be nested. For instance when a top level range consists of three 'steps', then opening a nested range will sub-divide that first step. When the nested range is closed, the first top-level step is finished and BeginNextStep() should be called on the top-level range. Subsequently the second step is active and can again be further subdivided with another nested plProgressRange.

Constructor & Destructor Documentation

◆ plProgressRange()

plProgressRange::plProgressRange ( plStringView sDisplayText,
plUInt32 uiSteps,
bool bAllowCancel,
plProgress * pProgressbar = nullptr )

Creates a progress range scope.

If any other progress range is currently active, it will become the parent range and the currently active step will be subdivided.

Parameters
szDisplayTextis the main display text for this range.
uiStepsis the number of steps that this range will be subdivided into
bAllowCancelspecifies whether the user can cancel this operation
pProgressbarcan be specified, if available, otherwise the currently active plProgress instance is used.

Member Function Documentation

◆ BeginNextStep()

bool plProgressRange::BeginNextStep ( plStringView sStepDisplayText,
plUInt32 uiNumSteps = 1 )

Should be called whenever a new sub-step is started to advance the progress.

Parameters
szStepDisplayTextThe sub-text for the next step to be displayed.
uiNumStepsHow many steps have been completed.
Returns
Returns false if the user clicked cancel.

◆ SetStepWeighting()

void plProgressRange::SetStepWeighting ( plUInt32 uiStep,
float fWeight )

Allows to weigh each step differently.

This makes it possible to divide an operation into two steps, but have one part take up 90% and the other 10%.

Parameters
uiStepThe index for the step to set the weight
fWeightThe weighting in [0; 1] range

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