12 #ifndef ARB_PROGRESS_H
13 #define ARB_PROGRESS_H
29 # define TEST_COUNTERS
32 #if !defined(DEVEL_RELEASE)
33 # define FORCE_WEIGHTED_ESTIMATION // see also ../WINDOW/AW_status.cxx@FORCEWEIGHTEDESTIMATION
36 #define DUMP_PROGRESS // undefine DUMP_PROGRESS again? (when progress bug #807 is fixed)
49 double phase2_weight()
const {
return 1.0-phase1_weight; }
59 phase1_weight(phase1_weight_)
68 double adjusted_gauge = linear_gauge;
70 if (linear_gauge<0.5) adjusted_gauge = phase1_weight * linear_gauge * 2;
71 else adjusted_gauge = phase1_weight + phase2_weight() * (linear_gauge-0.5)*2;
77 return adjusted_gauge;
95 virtual void inc() = 0;
97 virtual void inc_by(SINT count) = 0;
98 virtual void inc_to(SINT x) = 0;
101 virtual void done() = 0;
106 #if defined(DUMP_PROGRESS)
107 virtual void dump()
const = 0;
124 #if defined(DUMP_PROGRESS)
126 #define DUMP_AS(NAME) freedup(name,NAME)
128 #define DUMP_AS(NAME)
141 : reuse_allowed(
false),
142 has_title(has_title_),
149 #if defined(DUMP_PROGRESS)
153 #if defined(TEST_COUNTERS)
154 accept_invalid_counters =
false;
159 #if defined(TEST_COUNTERS)
160 bool accept_invalid_counters;
167 recent = prev_recent;
168 #if defined(DUMP_PROGRESS)
177 #if defined(FORCE_WEIGHTED_ESTIMATION)
185 virtual void set_text(
int level,
const char *text) = 0;
188 #if defined(DUMP_PROGRESS)
189 virtual void dump()
const;
214 bool owns(
const counter *pwnd)
const {
return cntr && cntr == pwnd; }
232 void setup(
const char *
title, PINT overall_count,
const double *phase1_fraction =
NULp) {
233 bool acceptInvalid =
false;
234 if (overall_count<0) {
235 GB_warningf(
"Warning: progress indicator underflow (%li, %s)\n"
236 "Please report to devel@arb-home.de\n"
237 "Estimation of time left is broken :/",
238 overall_count, title ? title :
"<no title>");
240 #if defined(DEVEL_RALF)
244 overall_count = 10L*INT_MAX;
245 acceptInvalid =
true;
249 if (acceptInvalid) accept_invalid_counters();
253 void accept_invalid_counters() {
254 #if defined(TEST_COUNTERS)
255 used->accept_invalid_counters =
true;
273 setup(title, overall_count);
288 setup(
NULp, overall_count);
309 template <
typename NUM>
arb_progress(
const char *t, NUM n);
315 arb_progress(
const char *title,
unsigned long overall_count) {
arb_assert(overall_count<=LONG_MAX); setup(title, overall_count); }
324 return aborted() ?
"Operation aborted on user request" :
NULp;
337 bool aborted_ = used->
aborted();
338 #if defined(TEST_COUNTERS)
339 if (aborted_) accept_invalid_counters();
368 #if defined(DUMP_PROGRESS)
387 #error arb_progress.h included twice
388 #endif // ARB_PROGRESS_H
virtual void inc_by(SINT count)=0
void inc_to_avoid_overflow(PINT x)
arb_progress(const char *title, unsigned long overall_count)
virtual void inc_to_avoid_overflow(SINT x)=0
bool owned_by(const nestable *by) const
virtual SmartPtr< nestable > create_child_progress(const char *title, SINT overall_count, const weightable &speed_)=0
static SmartPtr< nestable > create(const char *title, SINT overall_count, const double *phase1_fraction)
void child_sets_text(int level, const char *text)
virtual void update_gauge(double gauge)=0
void auto_subtitles(const char *prefix)
bool this_or_recent_is_weighted() const
virtual void force_update()=0
void inc_to_avoid_overflow(SINT x)
GB_ERROR error_if_aborted()
void sub_progress_skipped()
bool has_correct_ownership() const
virtual counter * clone(nestable *owner, SINT overall_count) const =0
virtual void set_text(int level, const char *text)=0
bool owns(const counter *pwnd) const
static void show_comment(const char *comment)
void GB_warningf(const char *templat,...)
nestable(counter *counter_, bool has_title_, const weightable &speed_)
virtual void child_updates_gauge(double gauge)=0
virtual bool has_auto_subtitles()=0
virtual void auto_subtitles(const char *prefix)=0
static bool have_weighted_progress()
arb_progress(unsigned long overall_count)
weightable(double phase1_weight_)
static void error(const char *msg)
void update_parent_gauge(double gauge)
const arb_progress & operator++()
arb_progress(WeightedProgressMarker, double phase1_fraction)
void auto_subtitles(const char *prefix)
virtual void implicit_inc()=0
void inc_and_check_user_abort(ARB_ERROR &error)
GB_ERROR inc_and_error_if_aborted()
static arb_status_implementation * impl
arb_progress(PINT overall_count)
arb_progress(const char *title)
arb_progress(WeightedProgressMarker, const char *title, double phase1_fraction)
static SmartPtr< nestable > create_suppressor()
double get_adjusted_gauge(double linear_gauge) const
void subtitle(const char *stitle)
virtual void inc_to(SINT x)=0
static void show_comment(const char *comment)
arb_progress(const char *title, PINT overall_count)
virtual void dump() const
arb_progress(char *title)
bool is_correct_owner() const
virtual void dump() const =0
void inc_and_check_user_abort(GB_ERROR &error)