Developer Documentation
ACG::Progress Class Reference

#include <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 90 of file Progress.hh.

Member Function Documentation

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

Does NOT take ownership of the supplied Progress object.

Definition at line 134 of file Progress.hh.

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 114 of file Progress.hh.


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