OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
WProgress Class Reference

Class managing progress inside of modules. More...

#include <WProgress.h>

+ Inheritance diagram for WProgress:
+ Collaboration diagram for WProgress:

Public Types

typedef std::shared_ptr< WProgressSPtr
 Shared pointer on a WProgress. More...
 
typedef std::shared_ptr< const WProgressConstSPtr
 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 WProgressoperator++ ()
 Simple increment operator to signal a forward stepping. More...
 
virtual WProgressoperator+ (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...
 

Detailed Description

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.

See also
WUI

Definition at line 41 of file WProgress.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WProgress > WProgress::ConstSPtr

Const Shared pointer on a WProgress.

Definition at line 53 of file WProgress.h.

◆ SPtr

typedef std::shared_ptr< WProgress > WProgress::SPtr

Shared pointer on a WProgress.

Definition at line 48 of file WProgress.h.

Constructor & Destructor Documentation

◆ WProgress()

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

Parameters
namename of the progress, can be empty.
countvalue denoting the final value. A value of zero will cause this progress to be indetermined.
Note
Reaching the count does not automatically stop the progress. You still need to call finish().
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::~WProgress ( )
virtual

Destructor.

Definition at line 47 of file WProgress.cpp.

Member Function Documentation

◆ finish()

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 WProgressCombiner::finish(), and WProgressTest::testFinish().

+ Here is the caller graph for this function:

◆ getName()

std::string WProgress::getName ( ) const

Returns the name of the progress.

Returns
name

Definition at line 78 of file WProgress.cpp.

References m_name.

◆ getProgress()

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ increment()

void WProgress::increment ( size_t  steps)
virtual

Increment the progress counter by the given amount.

Parameters
stepshow much

Definition at line 98 of file WProgress.cpp.

References operator+().

+ Here is the call graph for this function:

◆ isDetermined()

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

+ Here is the caller graph for this function:

◆ isPending()

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(), WProgressTest::testInternalState(), WProgressCombinerTest::testInternalStateIgnoresIncrementAndFinish(), and WProgressCombinerTest::testWithChilds().

+ Here is the caller graph for this function:

◆ operator+()

WProgress & WProgress::operator+ ( size_t  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.

Referenced by increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator++()

WProgress & WProgress::operator++ ( )
virtual

Simple increment operator to signal a forward stepping.

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

◆ update()

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

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WProgressTest

friend class WProgressTest
friend

Access for test class.

Definition at line 43 of file WProgress.h.

Member Data Documentation

◆ m_count

size_t WProgress::m_count
protected

◆ m_determined

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

◆ m_max

size_t WProgress::m_max
protected

The maximum count (which marks the 100%).

Definition at line 145 of file WProgress.h.

Referenced by finish(), getProgress(), operator+(), and WProgress().

◆ m_name

std::string WProgress::m_name
protected

Progress name.

Can be set only once (during construction).

Definition at line 140 of file WProgress.h.

Referenced by getName().

◆ m_pending

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


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