OpenWalnut
1.4.0
|
Class managing progress inside of modules. More...
#include <WProgress.h>
Public Types | |
typedef boost::shared_ptr < WProgress > | SPtr |
Shared pointer on a WProgress. | |
typedef boost::shared_ptr < const WProgress > | ConstSPtr |
Const Shared pointer on a WProgress. | |
Public Member Functions | |
WProgress (std::string name, size_t 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+ (size_t 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. | |
virtual void | increment (size_t steps) |
Increment the progress counter by the given amount. | |
Protected Attributes | |
std::string | m_name |
Progress name. | |
size_t | m_max |
The maximum count (which marks the 100%). | |
size_t | 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 WUI 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.
typedef boost::shared_ptr< const WProgress > WProgress::ConstSPtr |
Const Shared pointer on a WProgress.
Reimplemented in WProgressCombiner.
Definition at line 53 of file WProgress.h.
typedef boost::shared_ptr< WProgress > WProgress::SPtr |
Shared pointer on a WProgress.
Reimplemented in WProgressCombiner.
Definition at line 48 of file WProgress.h.
WProgress::WProgress | ( | std::string | name, |
size_t | 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().
void WProgress::increment | ( | size_t | steps | ) | [virtual] |
Increment the progress counter by the given amount.
steps | how much |
Definition at line 98 of file WProgress.cpp.
References operator+().
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().
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.
Referenced by increment().
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().
size_t WProgress::m_count [protected] |
The current counter.
Definition at line 150 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 160 of file WProgress.h.
Referenced by isDetermined(), WProgressCombiner::update(), and WProgress().
size_t WProgress::m_max [protected] |
The maximum count (which marks the 100%).
Definition at line 145 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 140 of file WProgress.h.
Referenced by getName().
bool WProgress::m_pending [protected] |
Flag denoting whether the progress is running or not.
Definition at line 155 of file WProgress.h.
Referenced by finish(), isPending(), WProgressCombiner::update(), and WProgressCombiner::WProgressCombiner().