12#ifndef ZYPP_CORE_UI_PROGRESSDATA_H
13#define ZYPP_CORE_UI_PROGRESSDATA_H
19#include <zypp/base/PtrTypes.h>
20#include <zypp/base/Function.h>
21#include <zypp-core/base/ProvideNumericId>
148 using TimePoint = std::chrono::steady_clock::time_point;
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; }
265 {
return set(
val() + val_r ); }
269 {
return set(
val() - val_r ); }
303 {
return min() !=
max(); }
326 const std::string &
name()
const
327 {
return _d->_name; }
331 {
return _d->_receiver; }
337 {
return(
_d->_state ==
END ); }
Progress callback from another progress.
bool operator()(const ProgressData &progress)
Implements the ProgressData::ReceiverFnc callback interface.
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.
bool report()
Send report if necessary.
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)
RW_pointer supporting 'copy on write' functionality.
Base class for objects providing a numeric Id.