libdnf5::cli::progressbar

enum class libdnf5::cli::progressbar::ProgressBarState : int

Values:

enumerator READY
enumerator STARTED
enumerator SUCCESS
enumerator WARNING
enumerator ERROR
enum class libdnf5::cli::progressbar::MessageType : int

Values:

enumerator INFO
enumerator SUCCESS
enumerator WARNING
enumerator ERROR
class DownloadProgressBar : public libdnf5::cli::progressbar::ProgressBar

Public Functions

explicit DownloadProgressBar(int64_t download_size, const std::string &description)
~DownloadProgressBar()
DownloadProgressBar(const DownloadProgressBar &src)
DownloadProgressBar &operator=(const DownloadProgressBar &src)
DownloadProgressBar(DownloadProgressBar &&src) noexcept
DownloadProgressBar &operator=(DownloadProgressBar &&src) noexcept
bool get_number_widget_visible() const noexcept
void set_number_widget_visible(bool value) noexcept
const std::vector<Message> &get_messages() const noexcept
void set_state(ProgressBarState value)
void set_ticks(int64_t value)
void set_total_ticks(int64_t value)
class MultiProgressBar

Methods to work with registered bars

Preferred way to modify a bar registered in this MultiProgressBar. Use these instead of calling ProgressBar methods directly, so that MultiProgressBar can track state changes and use them for rendering optimizations. Calls on a finished bar are ignored for mutating methods.

int64_t bar_get_ticks(ProgressBar &bar) const noexcept

Returns the number of processed ticks.

void bar_set_ticks(ProgressBar &bar, int64_t value)

Sets the number of processed ticks.

void bar_add_ticks(ProgressBar &bar, int64_t value)

Adds to the number of processed ticks.

int64_t bar_get_total_ticks(ProgressBar &bar) const noexcept

Returns the total number of ticks.

void bar_set_total_ticks(ProgressBar &bar, int64_t value)

Sets the total number of ticks.

int32_t bar_get_number(ProgressBar &bar) const noexcept

Returns the display number of the bar.

void bar_start(ProgressBar &bar)

Starts the bar (transitions from READY to STARTED).

ProgressBarState bar_get_state(ProgressBar &bar) const noexcept

Returns the current state.

void bar_set_state(ProgressBar &bar, ProgressBarState value)

Sets the state. Setting back to READY is not allowed.

bool bar_is_finished(ProgressBar &bar) const noexcept

Returns true if the bar has reached a terminal state (SUCCESS or ERROR).

bool bar_is_failed(ProgressBar &bar) const noexcept

Returns true if the bar is in the ERROR state.

std::string bar_get_description(ProgressBar &bar) const noexcept

Returns the description string.

void bar_set_description(ProgressBar &bar, const std::string &value)

Sets the description string.

void bar_add_message(ProgressBar &bar, MessageType type, const std::string &message)

Adds a message to the bar.

void bar_pop_message(ProgressBar &bar)

Removes the last message.

const std::vector<ProgressBar::Message> &bar_get_messages(ProgressBar &bar) const noexcept

Returns all messages.

const std::string &bar_get_message_prefix(ProgressBar &bar) const noexcept

Returns the message prefix string.

bool bar_get_auto_finish(ProgressBar &bar) const noexcept

Returns whether auto-finish is enabled.

void bar_set_auto_finish(ProgressBar &bar, bool value)

Enables or disables auto-finish. Disable to manage the terminal state manually.

int32_t bar_get_percent_done(ProgressBar &bar) const noexcept

Returns the percentage of ticks done (0–100).

int64_t bar_get_current_speed(ProgressBar &bar) const noexcept

Returns the current (recent) speed in ticks per second.

int64_t bar_get_average_speed(ProgressBar &bar) const noexcept

Returns the average speed in ticks per second.

int64_t bar_get_elapsed_seconds(ProgressBar &bar) const noexcept

Returns elapsed time in seconds.

int64_t bar_get_remaining_seconds(ProgressBar &bar) const noexcept

Returns estimated remaining time in seconds.

Public Types

enum class TrackingMode

Controls when bar state changes are processed for rendering.

Values:

enumerator ON_RENDER

All bars are scanned on every render to detect state changes.

enumerator ON_CHANGE

State changes are tracked incrementally via bar_*() wrapper methods. Much faster when many bars are registered but only a few are active.

Public Functions

explicit MultiProgressBar(TrackingMode tracking_mode)

Constructs a MultiProgressBar with the given tracking mode.

explicit MultiProgressBar()

Constructs a MultiProgressBar with TrackingMode::ON_RENDER.

~MultiProgressBar()
MultiProgressBar(const MultiProgressBar &src) = delete
MultiProgressBar &operator=(const MultiProgressBar &src) = delete
MultiProgressBar(MultiProgressBar &&src) noexcept = delete
MultiProgressBar &operator=(MultiProgressBar &&src) noexcept = delete
TrackingMode get_tracking_mode() const noexcept

Returns the tracking mode set at construction.

void add_bar(std::unique_ptr<ProgressBar> &&bar)
void print()
DownloadProgressBar &get_total_bar() noexcept

Returns the total bar.

void set_total_bar_visible_limit(std::size_t value) noexcept

Sets the minimum number of registered progress bars to show the total bar.

void set_total_bar_number_widget_visible(bool value) noexcept

Sets the visibility of number widget in the total bar.

void set_total_num_of_bars(std::size_t value) noexcept

Allows one to preset the value of the total number of progress bars. If the value is lower than the current number of registered progress bars, it is automatically increased.

std::size_t get_total_num_of_bars() const noexcept

Returns the total number of progress bars. It can be greater than the current number of registered progress bars.

Public Static Attributes

static constexpr std::size_t NEVER_VISIBLE_LIMIT = static_cast<std::size_t>(-1)

Friends

friend LIBDNF_CLI_API std::ostream & operator<< (std::ostream &stream, MultiProgressBar &mbar)
class ProgressBar

Subclassed by libdnf5::cli::progressbar::DownloadProgressBar

Public Types

using Message = std::pair<MessageType, std::string>

Public Functions

explicit ProgressBar(int64_t total_ticks)
explicit ProgressBar(int64_t total_ticks, const std::string &description)
virtual ~ProgressBar()
ProgressBar(const ProgressBar &src)
ProgressBar &operator=(const ProgressBar &src)
ProgressBar(ProgressBar &&src) noexcept
ProgressBar &operator=(ProgressBar &&src) noexcept
void reset()
int64_t get_ticks() const noexcept
void set_ticks(int64_t value)
void add_ticks(int64_t value)
int64_t get_total_ticks() const noexcept
void set_total_ticks(int64_t value)
int32_t get_number() const noexcept
void set_number(int32_t value)
int32_t get_total() const noexcept
void set_total(int32_t value)
void start()
ProgressBarState get_state() const noexcept
void set_state(ProgressBarState value)
bool is_finished() const noexcept
bool is_failed() const noexcept
std::string get_description() const noexcept
void set_description(const std::string &value)
std::size_t get_description_width() const noexcept
void add_message(MessageType type, const std::string &message)
void pop_message()

remove the last message

const std::vector<Message> &get_messages() const noexcept
const std::string &get_message_prefix() const noexcept
std::size_t calculate_messages_terminal_lines(std::size_t terminal_width)

Calculate number of lines occupied by messages when printed on terminal of the given width. Takes new lines and wide utf characters into account.

bool get_auto_finish() const noexcept
void set_auto_finish(bool value)
void update()
int32_t get_percent_done() const noexcept
int64_t get_current_speed() const noexcept
int64_t get_average_speed() const noexcept
int64_t get_elapsed_seconds() const noexcept
int64_t get_remaining_seconds() const noexcept
std::chrono::time_point<std::chrono::system_clock> get_begin()

Friends

friend LIBDNF_CLI_API std::ostream & operator<< (std::ostream &os, ProgressBar &bar)
class DescriptionWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
void set_total_width(std::size_t value)
inline void set_width(std::size_t value)
virtual std::string to_string() const override
class NumberWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
virtual std::string to_string() const override
class PercentWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
virtual std::string to_string() const override
class ProgressWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
inline std::size_t get_width() const noexcept
inline void set_width(std::size_t value)
virtual std::string to_string() const override
class SizeWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
virtual std::string to_string() const override
class SpeedWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
virtual std::string to_string() const override
class TimeWidget : public libdnf5::cli::progressbar::Widget

Public Functions

virtual std::size_t get_total_width() const noexcept override
virtual std::string to_string() const override
class Widget

Subclassed by libdnf5::cli::progressbar::DescriptionWidget, libdnf5::cli::progressbar::NumberWidget, libdnf5::cli::progressbar::PercentWidget, libdnf5::cli::progressbar::ProgressWidget, libdnf5::cli::progressbar::SizeWidget, libdnf5::cli::progressbar::SpeedWidget, libdnf5::cli::progressbar::TimeWidget

Public Functions

inline bool get_visible() const noexcept
inline void set_visible(bool value) noexcept
inline ProgressBar *get_bar() const noexcept
inline void set_bar(ProgressBar *value)
virtual std::size_t get_total_width() const noexcept = 0
virtual std::string to_string() const = 0
std::string to_spanned_string() const
inline const std::string &get_delimiter_before() const noexcept
inline void set_delimiter_before(const std::string &value)