Developer Documentation
ACG::Progress Class Reference

#include <OpenFlipper/libs_required/ACG/Utils/Progress.hh>

Classes

class  ChildRecord
 

Public Member Functions

 Progress (double maxProgress=1.0)
 
void setMaxProgress (double value)
 
double getNormalizedProgress () const
 
double getProgress () const
 
void addSubProgress (Progress *progress, double contribution)
 
void increment (double amount)
 

Protected Member Functions

void onChildProgress (Progress *)
 
void progressChanged ()
 
void updateDialog ()
 
void childGoesBye (Progress *child)
 

Protected Attributes

Progressparent
 
std::set< ChildRecordchildren
 
double maxProgress
 
double currentProgress
 
union {
   void *   dialog_padding
 
}; 
 

Private Member Functions

 Progress (const Progress &rhs)
 
Progressoperator= (const Progress &rhs)
 

Detailed Description

Keep track of the progress of tasks and subtasks.

Not thread safe. Could easily be made thread safe, though. See "Thread safety" comments in the source code.

Usage Example:

Progress p1(5.0);
p1.increment(1.0);
assert(p1.getNormalizedProgress() == 0.2);
p1.increment(4.0);
assert(p1.getNormalizedProgress() == 1.0);

Progress p2(10.0);
{
    Progress p2_1(10.0);
    p2.addSubProgress(&p2_1, 5.0);
    assert(p2.getNormalizedProgress() == 0.0);
    p2_1.increment(5.0);
    assert(p2_1.getNormalizedProgress() == 0.5);
    assert(p2.getNormalizedProgress() == 0.25);
}

// When the sub progress gets destroyed, the parent
// assumes it is completed.
assert(p2.getNormalizedProgress() == 0.5);

Definition at line 84 of file Progress.hh.

Constructor & Destructor Documentation

◆ Progress()

ACG::Progress::Progress ( double  maxProgress = 1.0)
inline

Definition at line 86 of file Progress.hh.

◆ ~Progress()

virtual ACG::Progress::~Progress ( )
inlinevirtual

Definition at line 88 of file Progress.hh.

Member Function Documentation

◆ addSubProgress()

void ACG::Progress::addSubProgress ( Progress progress,
double  contribution 
)
inline

Does NOT take ownership of the supplied Progress object.

Definition at line 128 of file Progress.hh.

◆ childGoesBye()

void ACG::Progress::childGoesBye ( Progress child)
inlineprotected

Definition at line 159 of file Progress.hh.

◆ getNormalizedProgress()

double ACG::Progress::getNormalizedProgress ( ) const
inline
Returns
A number in the interval [0, 1], 0 being no progress at all and 1 being a finished job.

Definition at line 108 of file Progress.hh.

◆ getProgress()

double ACG::Progress::getProgress ( ) const
inline

Definition at line 112 of file Progress.hh.

◆ increment()

void ACG::Progress::increment ( double  amount)
inline

Definition at line 137 of file Progress.hh.

◆ onChildProgress()

void ACG::Progress::onChildProgress ( Progress )
inlineprotected

Definition at line 143 of file Progress.hh.

◆ progressChanged()

void ACG::Progress::progressChanged ( )
inlineprotected

Definition at line 147 of file Progress.hh.

◆ setMaxProgress()

void ACG::Progress::setMaxProgress ( double  value)
inline

Definition at line 92 of file Progress.hh.

◆ updateDialog()

void ACG::Progress::updateDialog ( )
inlineprotected

Definition at line 152 of file Progress.hh.

Member Data Documentation

◆ children

std::set<ChildRecord> ACG::Progress::children
protected

Definition at line 182 of file Progress.hh.

◆ currentProgress

double ACG::Progress::currentProgress
protected

Definition at line 184 of file Progress.hh.

◆ dialog_padding

void* ACG::Progress::dialog_padding

Definition at line 194 of file Progress.hh.

◆ maxProgress

double ACG::Progress::maxProgress
protected

Definition at line 184 of file Progress.hh.

◆ parent

Progress* ACG::Progress::parent
protected

Definition at line 170 of file Progress.hh.


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