|
| | ProgressData () |
| | Ctor no range [0,0](0).
|
| | ProgressData (value_type max_r) |
| | Ctor [0,max](0).
|
| | ProgressData (value_type min_r, value_type max_r) |
| | Ctor [min,max](min).
|
| | ProgressData (value_type min_r, value_type max_r, value_type val_r) |
| | Ctor [min,max](val).
|
| | ~ProgressData () |
| void | min (value_type min_r) |
| | Set new min value.
|
| void | max (value_type max_r) |
| | Set new max value.
|
| void | noRange () |
| | Set no range [0,0].
|
| void | range (value_type max_r) |
| | Set new [0,max].
|
| void | range (value_type min_r, value_type max_r) |
| | Set new [min,max].
|
| void | name (const std::string &name_r) |
| | Set counter name.
|
| void | sendTo (const ReceiverFnc &fnc_r) |
| | Set ReceiverFnc.
|
| void | noSend () |
| | Set no ReceiverFnc.
|
These methods may actually cause a progress report to be sent.
All methods return bool, because a progress receiver may return false to indicate the desire to abort the pending action. The incident is logged, but it's finally up to the caller to honor this.
|
| bool | set (value_type val_r) |
| | Set new counter value.
|
| bool | set (const ProgressData &rhs) |
| | Set range and counter from an other ProgressData.
|
| bool | incr (value_type val_r=1) |
| | Increment counter value (default by 1).
|
| bool | decr (value_type val_r=1) |
| | Decrement counter value (default by 1).
|
| bool | toMin () |
| | Set counter value to current min value.
|
| bool | toMax () |
| | Set counter value to current max value (unless no range).
|
| bool | tick () |
| | Leave counter value unchanged (still alive).
|
| unsigned | numericId () const |
Maintain [min,max] and counter (value) for progress counting.
This class should provide everything the producer of progress data needs. As a convention, a zero sizes range indicates that you are just able to send 'still alive' triggers.
The counter should be updated in reasonable intervals. Don't mind whether the counter value actually increased or not. ProgressData will recognize your triggers and knows when to actually send notification to a consumer.
Each ProgressData object provides a unique numeric id and you may assign it a name.
{
return( ticks_r.
val() <= 100 );
}
class Example
{
public:
: _fnc( fnc_r )
{}
void SendTo( const ProgressData::ReceiverFnc & fnc_r )
{ _fnc = fnc_r; }
public:
void action()
{
ProgressData tics( 10 );
tics.name( "test ticks" );
tics.sendTo( _fnc );
tics.toMin();
for ( int i = 0; i < 10; ++i )
{
if ( ! tics.set( i ) )
return;
}
tics.toMax();
}
void action2()
{
ProgressData tics;
tics.name( "test ticks" );
tics.sendTo( _fnc );
tics.toMin();
for ( int i = 0; i < 10; ++i )
{
if ( ! tics.set( i ) )
return;
}
tics.toMax();
}
private:
ProgressData::ReceiverFnc _fnc;
};
value_type reportValue() const
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
ProgressData()
Ctor no range [0,0](0).
Example t( exampleReceiver );
DBG <<
"Reporting %:" << endl;
t.action();
DBG <<
"Reporting 'still alive':" << endl;
t.action2();
Reporting %:
got ->0 (0)
got ->10 (1)
got ->20 (2)
got ->30 (3)
got ->40 (4)
got ->50 (5)
got ->60 (6)
got ->70 (7)
got ->80 (8)
got ->90 (9)
got ->100 (10)
got ->100 (10)
Reporting 'still alive':
got ->-1 (0)
got ->-1 (9)
The different ammount of triggers is due to different rules for sending percent or 'still alive' messages.
Definition at line 131 of file progressdata.h.