OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Attributes | Friends
WProgressCombiner Class Reference

Base class for all kinds of progress combinations. More...

#include <WProgressCombiner.h>

+ Inheritance diagram for WProgressCombiner:

List of all members.

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 WProgressCombineroperator++ ()
 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

Detailed Description

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

WProgressCombiner::WProgressCombiner ( std::string  name = "") [explicit]

Default constructor.

It creates a empty combiner.

Parameters:
namethe (optional) name of this progress.

Definition at line 33 of file WProgressCombiner.cpp.

References WProgress::m_pending.

Destructor.

Definition at line 42 of file WProgressCombiner.cpp.


Member Function Documentation

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.

Parameters:
progressthe progress to add as a child.
Notes:
it is possible to add ProgressCombiner instances as well.

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.

Parameters:
excludeFinishedif true, the combined name list only contains unfinished progress'
Returns:
One describing string for all child progress names.

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'.

Returns:
the 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.

Notes:
this actually is for ++p. p++ is not useful since it returns a copy of WProgress with the old count.
Returns:
the incremented WProgress instance.

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.

Parameters:
progressthe 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.

Notes:
this method is expansive. It uses a lock to avoid concurrent write and iterates over this combiners children.

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().


Member Data Documentation

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().


The documentation for this class was generated from the following files: