OpenWalnut 1.2.5
Public Member Functions | Protected Attributes | Friends

WProgress Class Reference

Class managing progress inside of modules. More...

#include <WProgress.h>

Inheritance diagram for WProgress:

List of all members.

Public Member Functions

 WProgress (std::string name, unsigned int count=0)
 Creates a new progress instance as child of the specified progress.
virtual ~WProgress ()
 Destructor.
virtual void finish ()
 Stops the progress.
virtual WProgressoperator++ ()
 Simple increment operator to signal a forward stepping.
virtual WProgressoperator+ (unsigned int 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.

Protected Attributes

std::string m_name
 Progress name.
unsigned int m_max
 The maximum count (which marks the 100%).
unsigned int 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

Detailed Description

Class managing progress inside of modules.

It interacts with the abstract WGUI 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.

See also:
WGUI

Definition at line 41 of file WProgress.h.


Constructor & Destructor Documentation

WProgress::WProgress ( std::string  name,
unsigned int  count = 0 
)

Creates a new progress instance as child of the specified progress.

The instance is instantly marked "running".

Parameters:
namename of the progress, can be empty.
countvalue denoting the final value. A value of zero will cause this progress to be indetermined.
Notes:
Reaching the count does not automatically stop the progress. You still need to call finish().
Notes:
An indetermined progress is just indicating a pending progress without progress information.

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.


Member Function Documentation

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.

Returns:
name

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

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

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.

Returns:
false if no end point is known.

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.

Returns:
true if not finished.

Definition at line 73 of file WProgress.cpp.

References m_pending.

Referenced by WProgressTest::testFinish(), WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().

WProgress & WProgress::operator+ ( unsigned int  steps) [virtual]

Increments the operator by the given number of steps to signal forward progress.

Parameters:
stepsThe number of steps to increment
Returns:
the incremented WProgress instance.

Definition at line 88 of file WProgress.cpp.

References isDetermined(), m_count, and m_max.

WProgress & WProgress::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 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().


Member Data Documentation

unsigned int WProgress::m_count [protected]

The current counter.

Definition at line 135 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 145 of file WProgress.h.

Referenced by isDetermined(), WProgressCombiner::update(), and WProgress().

unsigned int WProgress::m_max [protected]

The maximum count (which marks the 100%).

Definition at line 130 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 125 of file WProgress.h.

Referenced by getName().

bool WProgress::m_pending [protected]

Flag denoting whether the progress is running or not.

Definition at line 140 of file WProgress.h.

Referenced by finish(), isPending(), WProgressCombiner::update(), and WProgressCombiner::WProgressCombiner().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends