12#ifndef ZYPP_CORE_UI_PROGRESSDATA_H
13#define ZYPP_CORE_UI_PROGRESSDATA_H
21#include <zypp-core/base/ProvideNumericId>
148 using TimePoint = std::chrono::steady_clock::time_point;
151 :
_state( INIT ), _min( min_r ), _max( max_r ), _val( val_r )
168 friend Data * rwcowClone<Data>(
const Data * rhs );
175 : _d( new
Data( 0, 0, 0 ) )
180 : _d( new
Data( 0, max_r, 0 ) )
185 : _d( new
Data( min_r, max_r, min_r ) )
190 : _d( new
Data( min_r, max_r, val_r ) )
195 if ( _d->_state == RUN )
205 { _d->_min = min_r; }
209 { _d->_max = max_r; }
217 { range( 0, max_r ); }
221 { min( min_r ); max( max_r ); }
225 void name(
const std::string & name_r )
226 { _d->_name = name_r; }
230 { _d->_receiver = fnc_r; }
260 return set( rhs.
val() );
265 {
return set( val() + val_r ); }
269 {
return set( val() - val_r ); }
273 {
return set( min() ); }
277 {
return hasRange() ? set( max() ) : tick(); }
303 {
return min() != max(); }
310 {
return hasRange(); }
317 {
return ! hasRange(); }
323 {
return hasRange() ? val() * 100 / ( max() - min() ) : -1; }
326 const std::string &
name()
const
327 {
return _d->_name; }
331 {
return _d->_receiver; }
337 {
return( _d->_state == END ); }
AutoDispose< void * > _state
Progress callback from another progress.
ProgressData::value_type _weight
ProgressData::value_type _last_value
std::chrono::steady_clock::time_point TimePoint
Data(value_type min_r, value_type max_r, value_type val_r)
Maintain [min,max] and counter (value) for progress counting.
bool tick()
Leave counter value unchanged (still alive).
bool decr(value_type val_r=1)
Decrement counter value (default by 1).
bool reportPercent() const
bool set(const ProgressData &rhs)
Set range and counter from an other ProgressData.
value_type reportValue() const
void noRange()
Set no range [0,0].
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
ProgressData(value_type min_r, value_type max_r)
Ctor [min,max](min).
const ReceiverFnc & receiver() const
ProgressData(value_type min_r, value_type max_r, value_type val_r)
Ctor [min,max](val).
bool toMax()
Set counter value to current max value (unless no range).
void name(const std::string &name_r)
Set counter name.
ProgressData(value_type max_r)
Ctor [0,max](0).
void noSend()
Set no ReceiverFnc.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
void max(value_type max_r)
Set new max value.
void range(value_type min_r, value_type max_r)
Set new [min,max].
void min(value_type min_r)
Set new min value.
bool incr(value_type val_r=1)
Increment counter value (default by 1).
const std::string & name() const
bool toMin()
Set counter value to current min value.
ProgressData()
Ctor no range [0,0](0).
bool set(value_type val_r)
Set new counter value.
RWCOW_pointer< Data > _d
Pointer to data.
void range(value_type max_r)
Set new [0,max].
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
ProgressData makeProgressData(const InputStream &input_r)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
RW_pointer supporting 'copy on write' functionality.
Base class for objects providing a numeric Id.