OpenWalnut
1.4.0
|
Base class for all kinds of progress combinations. More...
#include <WProgressCombiner.h>
Public Types | |
typedef boost::shared_ptr < WProgressCombiner > | SPtr |
Abbreviate shared_ptr for this class. | |
typedef boost::shared_ptr < const WProgressCombiner > | ConstSPtr |
Abbreviate shared_ptr for this class. | |
Public Member Functions | |
WProgressCombiner (std::string name="") | |
Default constructor. | |
virtual | ~WProgressCombiner () |
Destructor. | |
virtual void | finish () |
Stops the progress. | |
virtual WProgressCombiner & | operator++ () |
Simple increment operator to signal a forward stepping. | |
virtual float | getProgress () |
Returns the overall progress of this progress instance, including the child progress'. | |
virtual void | addSubProgress (boost::shared_ptr< WProgress > progress) |
Adds a new progress to this combiner. | |
virtual void | removeSubProgress (boost::shared_ptr< WProgress > progress) |
Removes the specified sub progress from this combiner. | |
virtual void | update () |
Function updating the internal state. | |
std::string | getCombinedNames (bool excludeFinished=false) const |
Generates a string combined out of every child progress name. | |
Protected Attributes | |
std::string | m_name |
The name of the combiner. | |
float | m_progress |
The current conglomerated progress. | |
std::set< boost::shared_ptr < WProgress > > | m_children |
Set of all child progress. | |
boost::shared_mutex | m_updateLock |
Lock for the above child set and the internal state update. | |
Friends | |
class | WProgressCombinerTest |
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 40 of file WProgressCombiner.h.
typedef boost::shared_ptr< const WProgressCombiner > WProgressCombiner::ConstSPtr |
Abbreviate shared_ptr for this class.
Reimplemented from WProgress.
Definition at line 52 of file WProgressCombiner.h.
typedef boost::shared_ptr< WProgressCombiner > WProgressCombiner::SPtr |
Abbreviate shared_ptr for this class.
Reimplemented from WProgress.
Definition at line 47 of file WProgressCombiner.h.
WProgressCombiner::WProgressCombiner | ( | std::string | name = "" | ) | [explicit] |
Default constructor.
It creates a empty combiner.
name | the (optional) name of this progress. |
Definition at line 33 of file WProgressCombiner.cpp.
References WProgress::m_pending.
WProgressCombiner::~WProgressCombiner | ( | ) | [virtual] |
Destructor.
Definition at line 42 of file WProgressCombiner.cpp.
void WProgressCombiner::addSubProgress | ( | boost::shared_ptr< WProgress > | progress | ) | [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 113 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
Referenced by WProgressCombinerTest::testWithChilds().
void WProgressCombiner::finish | ( | ) | [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 129 of file WProgressCombiner.cpp.
References 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 84 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
float WProgressCombiner::getProgress | ( | ) | [virtual] |
Returns the overall progress of this progress instance, including the child progress'.
Reimplemented from WProgress.
Definition at line 158 of file WProgressCombiner.cpp.
References m_progress.
Referenced by WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().
WProgressCombiner & WProgressCombiner::operator++ | ( | ) | [virtual] |
Simple increment operator to signal a forward stepping.
Reimplemented from WProgress.
Definition at line 152 of file WProgressCombiner.cpp.
void WProgressCombiner::removeSubProgress | ( | boost::shared_ptr< WProgress > | progress | ) | [virtual] |
Removes the specified sub progress from this combiner.
progress | the progress to remove. |
Definition at line 121 of file WProgressCombiner.cpp.
References m_children, and m_updateLock.
void WProgressCombiner::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 from WProgress.
Definition at line 47 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().
std::set< boost::shared_ptr< WProgress > > WProgressCombiner::m_children [protected] |
Set of all child progress.
Definition at line 136 of file WProgressCombiner.h.
Referenced by addSubProgress(), finish(), getCombinedNames(), removeSubProgress(), WProgressCombinerTest::testWithChilds(), and update().
std::string WProgressCombiner::m_name [protected] |
The name of the combiner.
Reimplemented from WProgress.
Definition at line 126 of file WProgressCombiner.h.
float WProgressCombiner::m_progress [protected] |
The current conglomerated progress.
Set by update().
Definition at line 131 of file WProgressCombiner.h.
Referenced by finish(), getProgress(), and update().
boost::shared_mutex WProgressCombiner::m_updateLock [mutable, protected] |
Lock for the above child set and the internal state update.
Definition at line 141 of file WProgressCombiner.h.
Referenced by addSubProgress(), finish(), getCombinedNames(), removeSubProgress(), and update().