DP3
Public Member Functions | Friends | List of all members
dp3::base::ProgressMeter Class Reference

Visual indication of a tasks progress. More...

#include <ProgressMeter.h>

Public Member Functions

 ProgressMeter ()
 
 ProgressMeter (double min, double max, const std::string &title, const std::string &subtitle, const std::string &minlabel, const std::string &maxlabel, bool estimateTime=true, int updateEvery=1)
 
 ~ProgressMeter ()
 
void update (double value, bool force=false)
 
double min () const
 
double max () const
 

Friends

class ObjectController
 

Detailed Description

Visual indication of a tasks progress.

This class shows the progress of a task. It is copied from casacore.

It shows the progress on stdout using a line with dots and percentages.

It is possible to attach the progressmeter to function in, say, a GUI that can show the progress in a more visual way.

The progress meter will usually be removed from the screen once the maximum value is set, so you should not reuse the ProgressMeter after that has happened. It is harmless, but it will not result in any visual feedback for the user.

While the "min" is usually less than "max", if in fact it is greater than "max" the progress meter will count down correctly.

For example:

void calculate(unsigned int n) {
int skip = n / 200;
ProgressMeter meter(0, n, "Title", "Subtitle", "", "", true, skip);
for (unsigned int i=0; i<n; i++) {
... calculate ...
meter.update(i);
}
}

Constructor & Destructor Documentation

◆ ProgressMeter() [1/2]

dp3::base::ProgressMeter::ProgressMeter ( )

Makes a null progress meter, i.e. no updates to the screen are generated.

◆ ProgressMeter() [2/2]

dp3::base::ProgressMeter::ProgressMeter ( double  min,
double  max,
const std::string &  title,
const std::string &  subtitle,
const std::string &  minlabel,
const std::string &  maxlabel,
bool  estimateTime = true,
int  updateEvery = 1 
)

Create a progress meter with the given min and max values and labels. if estimateTime=true, an estimate of the time remaining will be made for the user. This estimate assumes that the remaining portion will compute at the same rate as the portion completed so far, so the time should not be estimated for processes which are non-linear.

Any labels which are set to the empty string will have sensible defaults supplied. In particular, minlabel and maxlabel will be set to the display the minimum and maximum values.

Normally the progress bar will be updated with every call to update(). If however you will be sending many events then you might want to update the GUI every updateEvery'th event for efficiency. Generally there's no point updating more than a couple of hundred times since the eye can't distinguish differences in the progress bar position at that level. If updateEvery is <=0, it is set to 1 for you.

◆ ~ProgressMeter()

dp3::base::ProgressMeter::~ProgressMeter ( )

The destruction of the meter will cause an update to be sent with the maximum value. This will usually cause the GUI window to be removed from the screen. Thus the progress meter should generally live as long as the calculation it is tracking.

Member Function Documentation

◆ max()

double dp3::base::ProgressMeter::max ( ) const
inline

◆ min()

double dp3::base::ProgressMeter::min ( ) const
inline

Get the min and max values of the progress meter.

◆ update()

void dp3::base::ProgressMeter::update ( double  value,
bool  force = false 
)

Friends And Related Function Documentation

◆ ObjectController

friend class ObjectController
friend

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