#include <ProgressCounter.h>
Inheritance diagram for ProgressCounter:
Public Types | |
typedef unsigned | Bits |
enum | ChangedBit { VC_NONE = 0x00, VC_MIN = 0x01, VC_MAX = 0x02, VC_VAL = 0x04, VC_PERCENT = 0x10, VC_RANGE = (VC_MIN|VC_MAX), VC_COUNT = (VC_RANGE|VC_VAL), VC_ALL = (VC_COUNT|VC_PERCENT) } |
Public Member Functions | |
ProgressCounter (Bits initial_r=VC_NONE) | |
ProgressCounter (const ProgressData &pd_r, Bits initial_r=VC_NONE) | |
ProgressCounter & | operator= (const ProgressData &pd_r) |
virtual | ~ProgressCounter () |
virtual ProgressData & | min (int min_r) |
virtual ProgressData & | max (int max_r) |
virtual ProgressData & | range (int min_r, int max_r) |
virtual ProgressData & | set (int val_r) |
virtual ProgressData & | init (int min_r, int max_r, int val_r) |
bool | newMin () const |
bool | newMax () const |
bool | newVal () const |
bool | newRange () const |
bool | newPercent () const |
bool | needsUpdate () const |
double | fPercent (double ifepmty_r=0.0) const |
int | percent (int ifepmty_r=0) const |
void | tagDirty (Bits bits_r=VC_ALL) |
void | setDirty (Bits bits_r=VC_ALL) |
Bits | update () |
bool | updateIfNewPercent (unsigned limit_r=0) |
void | reset () |
Protected Member Functions | |
virtual Bits | onUpdate () |
Private Member Functions | |
void | check (int lhs, int rhs, ChangedBit which) |
bool | checkPercent () const |
Private Attributes | |
Bits | _changed |
int | _oldPercent |
Friends | |
std::ostream & | operator<< (std::ostream &str, const ProgressCounter &obj) |
ProgressCounter overloads all value manipulating methods ot the inherited and remembers changing values in a bitmask.
A call to update discards previously remembered changes. onUpdate is what derived classes may want to overload, to perform whatever action on a call to update and set the bits returned to the caller.
|
|
|
Bits and bitmasks |
|
Constructor. |
|
Constructor. |
|
Destructor. |
|
Test before value assignment. Set ChangedBit if current an new value differ. |
|
Test for changed percent value.
|
|
Calculate percentage (as double). If |
|
Overloaded ProgressData::init to check for changed value. Reimplemented from ProgressData. |
|
Overloaded ProgressData::max to check for changed value. Reimplemented from ProgressData. |
|
Overloaded ProgressData::min to check for changed value. Reimplemented from ProgressData. |
|
Whether any value changed since last update. |
|
Whether max value changed since last update. |
|
Whether min value changed since last update. |
|
|
Whether min or max value changed since last update. |
|
Whether counter value changed since last update. |
|
Derived classes may want to overload this to trigger whatever action.
|
|
Assign new ProgressData. Reimplemented from ProgressData. |
|
Calculate percentage (as int). If |
|
Overloaded ProgressData::range to check for changed value. Reimplemented from ProgressData. |
|
Reset all values to 0 and tag all values dirty. |
|
Overloaded ProgressData::set to check for changed value. Reimplemented from ProgressData. |
|
Set remembered changes to bits. |
|
Add bits to remembered changes. |
|
Discard all previously remembered changes. Derived classes want to overload onUpdate. The caller may interpret the bits returned as 'unprocessed changes'.
|
|
Call update, if newPercent or if all flags are set dirty (e.g. after reset).
If a nonzero limit_r is provided, and old and new percentage differ less than limit_r, a call to update is omitted. Thus However, if the old percentage was at min or max, or if the new percentage hits min or max, update is called regardless to the limit_r.
|
|
|
|
Changed values in ProgressData since last update. Mutable because some bits like VC_PERCENT may be set when needed, and not on every value change. |
|