Skip to content

PGProgressManager

struct PGProgressManager

Singleton manager for stacked progress bar display.

In TUI mode: emits JSONL progress messages, does not use indicators display. In classic mode: delegates to indicators::DynamicProgress for ANSI rendering.

If forgeview dies mid-run, automatically switches to classic mode and re-registers all active bars with the indicators display.

Variables

Name Description
owned_bars Owns the bars so they outlive the DynamicProgress reference wrappers.
registered_with_display Whether each bar has been registered with indicators::DynamicProgress.
display Stacked display container — references bars in owned_bars.
mu Mutex for thread-safe output.

Functions

Name Description
PGProgressManager Next progress bar ID for JSONL messages.
ensure_tui_or_fallback Check if forgeview is still alive; if dead, switch to classic spdlog+indicators mode. Must be called with mu held.
add Register a new bar.
tick Tick a bar.
done Mark a bar as completed.
metrics Emit metrics for convergence monitoring.

Variable Details

display

indicators::DynamicProgress<PGProgressBar> display

Stacked display container — references bars in owned_bars. Only used in classic (non-TUI) mode.

mu

std::mutex mu

Mutex for thread-safe output.

owned_bars

std::vector<std::shared_ptr<PGProgressBar>> owned_bars

Owns the bars so they outlive the DynamicProgress reference wrappers.

registered_with_display

std::vector<bool> registered_with_display

Whether each bar has been registered with indicators::DynamicProgress.

Function Details

PGProgressManager

PGProgressManager()

Next progress bar ID for JSONL messages.

add

size_t add(std::shared_ptr<PGProgressBar> bar, const std::string& label, size_t max_progress)

Register a new bar. In TUI mode, emits JSONL "add" and returns an index. In classic mode, adds to indicators::DynamicProgress.

done

void done(size_t idx, const std::string& error = "")

Mark a bar as completed.

idx : Bar index from add().

error : Optional error message; if non-empty, included in JSONL done message.

ensure_tui_or_fallback

void ensure_tui_or_fallback()

Check if forgeview is still alive; if dead, switch to classic spdlog+indicators mode. Must be called with mu held.

metrics

void metrics(size_t bar_id, size_t iter, double error_norm, double penalty)

Emit metrics for convergence monitoring.
In TUI mode: emits JSONL. In classic mode: logs a readable summary.

tick

void tick(size_t idx, size_t current, const std::string& postfix = "")

Tick a bar. In TUI mode, emits JSONL "tick".