Class managing progress inside of modules. More...
#include <WProgress.h>
Public Member Functions | |
WProgress (std::string name, unsigned int count=0) | |
Creates a new progress instance as child of the specified progress. | |
virtual | ~WProgress () |
Destructor. | |
virtual void | finish () |
Stops the progress. | |
virtual WProgress & | operator++ () |
Simple increment operator to signal a forward stepping. | |
virtual WProgress & | operator+ (unsigned int steps) |
Increments the operator by the given number of steps to signal forward progress. | |
virtual float | getProgress () |
Returns the overall progress of this progress instance, including the child progress'. | |
virtual bool | isPending () |
Returns true when the operation is pending. | |
std::string | getName () const |
Returns the name of the progress. | |
virtual void | update () |
Function updating the internal state. | |
virtual bool | isDetermined () |
Returns true whenever the progress has a known end. | |
Protected Attributes | |
std::string | m_name |
Progress name. | |
unsigned int | m_max |
The maximum count (which marks the 100%). | |
unsigned int | m_count |
The current counter. | |
bool | m_pending |
Flag denoting whether the progress is running or not. | |
bool | m_determined |
True if the progress has a known end point. | |
Friends | |
class | WProgressTest |
Class managing progress inside of modules.
It interacts with the abstract WGUI class to present those information to the user. At the same time, it also is a simple tree structure, allowing the programmer to arrange complex sub progress. This is especially useful if several time-consuming tasks need to be performed.
Definition at line 41 of file WProgress.h.
WProgress::WProgress | ( | std::string | name, | |
unsigned int | count = 0 | |||
) |
Creates a new progress instance as child of the specified progress.
The instance is instantly marked "running".
name | name of the progress, can be empty. | |
count | value denoting the final value. A value of zero will cause this progress to be indetermined. |
Definition at line 33 of file WProgress.cpp.
References m_determined, and m_max.
WProgress::~WProgress | ( | ) | [virtual] |
Destructor.
Definition at line 47 of file WProgress.cpp.
void WProgress::finish | ( | ) | [virtual] |
Stops the progress.
After finishing, the progress de-registers from its parent (if any).
Reimplemented in WProgressCombiner.
Definition at line 57 of file WProgress.cpp.
References m_count, m_max, and m_pending.
Referenced by WProgressTest::testFinish().
std::string WProgress::getName | ( | ) | const |
Returns the name of the progress.
Definition at line 78 of file WProgress.cpp.
References m_name.
float WProgress::getProgress | ( | ) | [virtual] |
Returns the overall progress of this progress instance, including the child progress'.
Reimplemented in WProgressCombiner.
Definition at line 68 of file WProgress.cpp.
References isDetermined(), m_count, and m_max.
Referenced by WProgressTest::testInternalState(), and WProgressTest::testInternalStateOfIndetermined().
bool WProgress::isDetermined | ( | ) | [virtual] |
Returns true whenever the progress has a known end.
If this instance has m_max==0 then this will be false, as there is no known end point.
Definition at line 83 of file WProgress.cpp.
References m_determined.
Referenced by getProgress(), operator+(), WProgressTest::testDeterminedFlag(), and WProgressCombinerTest::testWithChilds().
bool WProgress::isPending | ( | ) | [virtual] |
Returns true when the operation is pending.
After calling finish() this will always return false.
Definition at line 73 of file WProgress.cpp.
References m_pending.
Referenced by WProgressTest::testFinish(), WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
WProgress & WProgress::operator+ | ( | unsigned int | steps | ) | [virtual] |
Increments the operator by the given number of steps to signal forward progress.
steps | The number of steps to increment |
Definition at line 88 of file WProgress.cpp.
References isDetermined(), m_count, and m_max.
WProgress & WProgress::operator++ | ( | ) | [virtual] |
Simple increment operator to signal a forward stepping.
Reimplemented in WProgressCombiner.
Definition at line 63 of file WProgress.cpp.
void WProgress::update | ( | ) | [virtual] |
Function updating the internal state.
This needs to be called before any get function to ensure the getter return the right values.
Reimplemented in WProgressCombiner.
Definition at line 52 of file WProgress.cpp.
Referenced by WProgressTest::testInternalState(), and WProgressTest::testInternalStateOfIndetermined().
unsigned int WProgress::m_count [protected] |
The current counter.
Definition at line 135 of file WProgress.h.
Referenced by finish(), getProgress(), and operator+().
bool WProgress::m_determined [protected] |
True if the progress has a known end point.
Definition at line 145 of file WProgress.h.
Referenced by isDetermined(), WProgressCombiner::update(), and WProgress().
unsigned int WProgress::m_max [protected] |
The maximum count (which marks the 100%).
Definition at line 130 of file WProgress.h.
Referenced by finish(), getProgress(), operator+(), and WProgress().
std::string WProgress::m_name [protected] |
Progress name.
Can be set only once (during construction).
Reimplemented in WProgressCombiner.
Definition at line 125 of file WProgress.h.
Referenced by getName().
bool WProgress::m_pending [protected] |
Flag denoting whether the progress is running or not.
Definition at line 140 of file WProgress.h.
Referenced by finish(), isPending(), WProgressCombiner::update(), and WProgressCombiner::WProgressCombiner().