OpenWalnut
1.5.0dev
|
Class managing progress inside of modules. More...
#include <WProgress.h>
Public Types | |
typedef std::shared_ptr< WProgress > | SPtr |
Shared pointer on a WProgress. More... | |
typedef std::shared_ptr< const WProgress > | ConstSPtr |
Const Shared pointer on a WProgress. More... | |
Public Member Functions | |
WProgress (std::string name, size_t count=0) | |
Creates a new progress instance as child of the specified progress. More... | |
virtual | ~WProgress () |
Destructor. More... | |
virtual void | finish () |
Stops the progress. More... | |
virtual WProgress & | operator++ () |
Simple increment operator to signal a forward stepping. More... | |
virtual WProgress & | operator+ (size_t steps) |
Increments the operator by the given number of steps to signal forward progress. More... | |
virtual float | getProgress () |
Returns the overall progress of this progress instance, including the child progress'. More... | |
virtual bool | isPending () |
Returns true when the operation is pending. More... | |
std::string | getName () const |
Returns the name of the progress. More... | |
virtual void | update () |
Function updating the internal state. More... | |
virtual bool | isDetermined () |
Returns true whenever the progress has a known end. More... | |
virtual void | increment (size_t steps) |
Increment the progress counter by the given amount. More... | |
Protected Attributes | |
std::string | m_name |
Progress name. More... | |
size_t | m_max |
The maximum count (which marks the 100%). More... | |
size_t | m_count |
The current counter. More... | |
bool | m_pending |
Flag denoting whether the progress is running or not. More... | |
bool | m_determined |
True if the progress has a known end point. More... | |
Friends | |
class | WProgressTest |
Access for test class. More... | |
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 std::shared_ptr< const WProgress > WProgress::ConstSPtr |
Const Shared pointer on a WProgress.
Definition at line 53 of file WProgress.h.
typedef std::shared_ptr< WProgress > WProgress::SPtr |
Shared pointer on a WProgress.
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.
|
virtual |
Destructor.
Definition at line 47 of file WProgress.cpp.
|
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 WProgressCombiner::finish(), and WProgressTest::testFinish().
std::string WProgress::getName | ( | ) | const |
Returns the name of the progress.
Definition at line 78 of file WProgress.cpp.
References m_name.
|
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().
|
virtual |
Increment the progress counter by the given amount.
steps | how much |
Definition at line 98 of file WProgress.cpp.
References operator+().
|
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().
|
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(), WProgressTest::testInternalState(), WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
|
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.
Referenced by increment().
|
virtual |
Simple increment operator to signal a forward stepping.
Reimplemented in WProgressCombiner.
Definition at line 63 of file WProgress.cpp.
|
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().
|
friend |
Access for test class.
Definition at line 43 of file WProgress.h.
|
protected |
The current counter.
Definition at line 150 of file WProgress.h.
Referenced by finish(), getProgress(), operator+(), WProgressTest::testInternalState(), and WProgressTest::testInternalStateOfIndetermined().
|
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().
|
protected |
The maximum count (which marks the 100%).
Definition at line 145 of file WProgress.h.
Referenced by finish(), getProgress(), operator+(), and WProgress().
|
protected |
Progress name.
Can be set only once (during construction).
Definition at line 140 of file WProgress.h.
Referenced by getName().
|
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().