37 #if defined(DUMP_PROGRESS)
39 fprintf(stderr,
"null_counter\n");
53 #if defined(DUMP_PROGRESS)
55 fprintf(stderr,
"no_counter (=wrapped null_counter)\n");
68 SINT explicit_counter;
69 SINT implicit_counter;
71 double autoUpdateEvery;
72 double nextAutoUpdate;
73 char *auto_subtitle_prefix;
74 SINT last_auto_counter;
76 SINT dispositive_counter()
const {
return std::max(implicit_counter, explicit_counter); }
83 maxcount = overallCount;
84 autoUpdateEvery = overallCount/500.0;
88 bool refresh_if_needed(
double my_counter) {
90 if (my_counter<nextAutoUpdate)
return false;
93 double gauge = my_counter/maxcount;
95 SINT new_maxcount = maxcount*1.2+0.5;
98 "Estimation of time left is broken (assuming new maximum: +20%% -> %li)\n"
99 "Please report this problem to devel@arb-home.de\n"
100 "(please mention the full text shown in the progress bar window\n"
101 "AND include the newest session log (stored after quitting arb),\n"
102 "otherwise we'll not be able to fix this problem)",
103 (gauge-1)*100, maxcount, new_maxcount);
110 maxcount = new_maxcount;
111 gauge = my_counter/maxcount;
113 ownedBy->update_gauge(gauge);
116 if (auto_subtitle_prefix) {
118 if (count>last_auto_counter && count <= maxcount) {
119 last_auto_counter = count;
120 const char *autosub =
GBS_global_string(
"%s #%li/%li", auto_subtitle_prefix, count, maxcount);
124 nextAutoUpdate += autoUpdateEvery;
127 void update_display_if_needed() {
128 refresh_if_needed(dispositive_counter());
132 double oldNext = nextAutoUpdate;
134 update_display_if_needed();
135 nextAutoUpdate = oldNext;
141 auto_subtitle_prefix(
NULp),
148 free(auto_subtitle_prefix);
149 #if defined(TEST_COUNTERS)
150 if (!ownedBy->accept_invalid_counters) {
151 arb_assert(implicit_counter || explicit_counter);
156 arb_assert(dispositive_counter() == maxcount);
161 #if defined(DUMP_PROGRESS)
164 "concrete_counter: explicit=%li, implicit=%li, maxcount=%li\n",
165 explicit_counter, implicit_counter, maxcount);
172 freedup(auto_subtitle_prefix, prefix);
177 void inc()
OVERRIDE { explicit_counter += 1; update_display_if_needed(); }
181 explicit_counter =
std::max(explicit_counter, x);
182 update_display_if_needed();
190 implicit_counter = explicit_counter = maxcount;
195 return new concrete_counter(owner, overall_count);
198 refresh_if_needed(dispositive_counter()+child_gauge);
208 return GBS_global_string(
" (weighted: %.3f%%:%.3f%%)", phase1_weight*100, (1-phase1_weight)*100);
212 if (overall_count)
return new concrete_counter(owner, overall_count);
218 static child_progress *child_triggering_update;
229 parent->child_terminated();
233 return new child_progress(
this,
title, overall_count, speed_);
236 #if defined(DUMP_PROGRESS)
239 fprintf(stderr,
"is child of\n");
244 void set_text(
int level,
const char *text)
OVERRIDE { parent->child_sets_text(level+has_title-1, text); }
247 double adjusted_gauge = speed.get_adjusted_gauge(gauge);
248 if (!child_triggering_update) {
250 parent->update_parent_gauge(adjusted_gauge);
253 parent->update_parent_gauge(adjusted_gauge);
260 child_progress *child_progress::child_triggering_update =
NULp;
264 fprintf(stderr,
"-------------------- warn_and_dump_counter_or_calling_progress [start]\n");
265 fputs(warnmsg, stderr);
267 #if defined(DUMP_PROGRESS)
268 const child_progress *updater = child_progress::calling_child_progress();
276 fprintf(stderr,
"-------------------- warn_and_dump_counter_or_calling_progress [end]\n");
286 if (!title) title =
"...";
287 impl->openstatus(title);
295 return new child_progress(
this,
title, overall_count, speed_);
300 switch (level+has_title-1) {
303 #if defined(FORCE_WEIGHTED_ESTIMATION)
304 if (speed.is_weighted() || have_weighted_progress()) {
305 cntr->force_update();
306 impl->set_subtitle(
"REQUEST_ESTIMATION");
309 impl->set_subtitle(text);
318 double adjusted_gauge = speed.get_adjusted_gauge(gauge);
319 impl->set_gauge(adjusted_gauge);
331 nestable(counter_to_clone->
clone(
this, overall_count),
false, speed_)
333 DUMP_AS(
"null_progress (cloned)");
339 DUMP_AS(
"null_progress (suppressor)");
372 #if defined(FORCE_WEIGHTED_ESTIMATION)
387 #if defined(DUMP_PROGRESS)
392 fprintf(stderr,
"progress %s\n",
name);
393 fprintf(stderr,
"counter: ");
398 fprintf(stderr,
"--------------------\n");
initial_selfRef_progress(const char *title, SINT overall_count, const weightable &speed_)
void child_updates_gauge(double child_gauge) OVERRIDE
concrete_counter(nestable *owner, SINT overall_count)
void GB_warning(const char *message)
SmartPtr< nestable > create_child_progress(const char *title, SINT overall_count, const weightable &speed_) OVERRIDE
#define implicated(hypothesis, conclusion)
void inc_by(SINT) OVERRIDE
void implicit_inc() OVERRIDE
void implicit_inc() OVERRIDE
virtual SmartPtr< nestable > create_child_progress(const char *title, SINT overall_count, const weightable &speed_)=0
~child_progress() OVERRIDE
static SmartPtr< nestable > create(const char *title, SINT overall_count, const double *phase1_fraction)
initial_progress(const char *title, counter *counter_, const weightable &speed_)
void set_text(int, const char *) OVERRIDE
const char * GBS_global_string(const char *templat,...)
void update_gauge(double gauge) OVERRIDE
bool this_or_recent_is_weighted() const
bool has_auto_subtitles() OVERRIDE
null_counter(nestable *owner)
no_counter(nestable *owner)
virtual counter * clone(nestable *owner, SINT overall_count) const =0
arb_handlers * active_arb_handlers
static counter * make_counter(nestable *owner, SINT overall_count)
static void warn_and_dump_counter_or_calling_progress(const char *warnmsg, const counter *fallback)
void child_updates_gauge(double gauge) OVERRIDE
void force_update() OVERRIDE
static bool have_weighted_progress()
~initial_progress() OVERRIDE
void inc_to_avoid_overflow(SINT x) OVERRIDE
void inc_to_avoid_overflow(SINT) OVERRIDE
counter * clone(nestable *owner, SINT overall_count) const OVERRIDE
counter * clone(nestable *, SINT) const OVERRIDE
void set_text(int level, const char *text) OVERRIDE
const char * spaced_weightable(const weightable &speed)
SmartPtr< nestable > create_child_progress(const char *title, SINT overall_count, const weightable &speed_) OVERRIDE
void auto_subtitles(const char *) OVERRIDE
static arb_status_implementation * impl
fputs(TRACE_PREFIX, stderr)
void update_gauge(double) OVERRIDE
static SmartPtr< nestable > create_suppressor()
void inc_to(SINT) OVERRIDE
double get_adjusted_gauge(double linear_gauge) const
~concrete_counter() OVERRIDE
static ARB_init_perl_interface init
void set_text(int level, const char *text) OVERRIDE
void auto_subtitles(const char *prefix) OVERRIDE
bool has_auto_subtitles() OVERRIDE
virtual void dump() const
void child_updates_gauge(double) OVERRIDE
SmartPtr< nestable > create_child_progress(const char *, SINT overall_count, const weightable &speed_) OVERRIDE
arb_status_implementation status
child_progress(nestable *parent_, const char *title, SINT overall_count, const weightable &speed_)
static const child_progress * calling_child_progress()
counter * clone(nestable *owner, SINT) const OVERRIDE
virtual void dump() const =0
void inc_to(SINT x) OVERRIDE
char * GBS_global_string_copy(const char *templat,...)
void update_gauge(double gauge) OVERRIDE