OpenWalnut
1.5.0dev
|
Base class for all kinds of progress combinations. More...
#include <WProgressCombiner.h>
Public Types | |
typedef std::shared_ptr< WProgressCombiner > | SPtr |
Abbreviate shared_ptr for this class. More... | |
typedef std::shared_ptr< const WProgressCombiner > | ConstSPtr |
Abbreviate shared_ptr for this class. More... | |
Public Types inherited from WProgress | |
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 | |
WProgressCombiner (std::string name="") | |
Default constructor. More... | |
virtual | ~WProgressCombiner () |
Destructor. More... | |
virtual void | finish () |
Stops the progress. More... | |
virtual WProgressCombiner & | operator++ () |
Simple increment operator to signal a forward stepping. More... | |
virtual float | getProgress () |
Returns the overall progress of this progress instance, including the child progress'. More... | |
virtual void | addSubProgress (std::shared_ptr< WProgress > progress) |
Adds a new progress to this combiner. More... | |
virtual void | removeSubProgress (std::shared_ptr< WProgress > progress) |
Removes the specified sub progress from this combiner. More... | |
virtual void | update () |
Function updating the internal state. More... | |
std::string | getCombinedNames (bool excludeFinished=false) const |
Generates a string combined out of every child progress name. More... | |
Public Member Functions inherited from WProgress | |
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 WProgress & | operator+ (size_t steps) |
Increments the operator by the given number of steps to signal forward 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 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 |
The name of the combiner. More... | |
float | m_progress |
The current conglomerated progress. More... | |
std::set< std::shared_ptr< WProgress > > | m_children |
Set of all child progress. More... | |
std::shared_mutex | m_updateLock |
Lock for the above child set and the internal state update. More... | |
Protected Attributes inherited from WProgress | |
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 | WProgressCombinerTest |
Access for test class. More... | |
Base class for all kinds of progress combinations.
You might want to derive from this class to implement some special progress combination.
Definition at line 41 of file WProgressCombiner.h.
typedef std::shared_ptr< const WProgressCombiner > WProgressCombiner::ConstSPtr |
Abbreviate shared_ptr for this class.
Definition at line 53 of file WProgressCombiner.h.
typedef std::shared_ptr< WProgressCombiner > WProgressCombiner::SPtr |
Abbreviate shared_ptr for this class.
Definition at line 48 of file WProgressCombiner.h.
|
explicit |
Default constructor.
It creates a empty combiner.
name | the (optional) name of this progress. |
Definition at line 34 of file WProgressCombiner.cpp.
References WProgress::m_pending.
|
virtual |
Destructor.
Definition at line 43 of file WProgressCombiner.cpp.
|
virtual |
Adds a new progress to this combiner.
It does not check whether the specified progress already is associated with another combiner, which allows some kind of "shared" progress. The progress stays in the progress list until finish() is called, which actually cleans up and resets a combiner.
progress | the progress to add as a child. |
Definition at line 114 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
Referenced by WProgressCombinerTest::testWithChilds().
|
virtual |
Stops the progress.
Progress combiner propagate this request to their children. Please not that this operation is expansive. It locks the updateLock and removes all child progress.
Reimplemented from WProgress.
Definition at line 130 of file WProgressCombiner.cpp.
References WProgress::finish(), m_children, m_progress, and m_updateLock.
Referenced by WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
std::string WProgressCombiner::getCombinedNames | ( | bool | excludeFinished = false | ) | const |
Generates a string combined out of every child progress name.
excludeFinished | if true, the combined name list only contains unfinished progress' |
Definition at line 85 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
|
virtual |
Returns the overall progress of this progress instance, including the child progress'.
Reimplemented from WProgress.
Definition at line 159 of file WProgressCombiner.cpp.
References m_progress.
Referenced by WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
|
virtual |
Simple increment operator to signal a forward stepping.
Reimplemented from WProgress.
Definition at line 153 of file WProgressCombiner.cpp.
|
virtual |
Removes the specified sub progress from this combiner.
progress | the progress to remove. |
Definition at line 122 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
|
virtual |
Function updating the internal state.
This needs to be called before any get function to ensure the getter return the right values.
Reimplemented from WProgress.
Definition at line 48 of file WProgressCombiner.cpp.
References m_children, WProgress::m_determined, WProgress::m_pending, m_progress, and m_updateLock.
Referenced by WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
|
friend |
Access for test class.
Definition at line 43 of file WProgressCombiner.h.
|
protected |
Set of all child progress.
Definition at line 137 of file WProgressCombiner.h.
Referenced by addSubProgress(), finish(), getCombinedNames(), removeSubProgress(), WProgressCombinerTest::testWithChilds(), and update().
|
protected |
The name of the combiner.
Definition at line 127 of file WProgressCombiner.h.
|
protected |
The current conglomerated progress.
Set by update().
Definition at line 132 of file WProgressCombiner.h.
Referenced by finish(), getProgress(), and update().
|
mutableprotected |
Lock for the above child set and the internal state update.
Definition at line 142 of file WProgressCombiner.h.
Referenced by addSubProgress(), finish(), getCombinedNames(), removeSubProgress(), and update().