13#include <zypp/base/Logger.h>
14#include <zypp-core/base/InputStream>
15#include <zypp/base/String.h>
17#include <zypp-core/ui/ProgressData>
21#undef ZYPP_BASE_LOGGER_LOGGROUP
22#define ZYPP_BASE_LOGGER_LOGGROUP "Progress"
35 static constexpr std::chrono::milliseconds minfequency { 1000 };
36 static constexpr std::chrono::milliseconds maxfequency { 100 };
38 Data::TimePoint::duration elapsed { now -
_d->_last_send };
39 if ( elapsed < maxfequency ) {
48 if ( elapsed > minfequency
49 || newVal !=
_d->_last_val
50 ||
_d->_state !=
RUN )
52 _d->_last_val = newVal;
60 if ( elapsed > minfequency ||
_d->_state !=
RUN )
62 _d->_last_val =
_d->_val;
79 if ( !
_d->_receiver( *
this ) )
81 if (
_d->_state !=
END )
83 WAR <<
"User request to ABORT pending action. "
85 _d->_last_val, (
hasRange() ?
"%" :
"!" ) ) << endl;
90 else if (
_d->_state ==
END )
107 return str <<
str::form(
"{%u|%s}[%lld,%lld](%lld)%lld%%)",
125 if ( input_r.
size() > 0 )
149 float real_increment = parent_factor*increment;
bool operator()(const ProgressData &progress)
Implements the ProgressData::ReceiverFnc callback interface.
ProgressData::value_type _weight
CombinedProgressData(ProgressData &pd, ProgressData::value_type weight=0)
Ctor.
ProgressData::value_type _last_value
std::chrono::steady_clock::time_point TimePoint
Maintain [min,max] and counter (value) for progress counting.
bool tick()
Leave counter value unchanged (still alive).
value_type reportValue() const
void name(const std::string &name_r)
Set counter name.
bool report()
Send report if necessary.
void max(value_type max_r)
Set new max value.
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
RWCOW_pointer< Data > _d
Pointer to data.
void range(value_type max_r)
Set new [0,max].
String related utilities and Regular expression matching.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
ProgressData makeProgressData(const InputStream &input_r)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
unsigned numericId() const