MCPcopy Create free account
hub / github.com/KTH-RPL/dufomap / IndeterminateProgressBar

Class IndeterminateProgressBar

src/indicators.hpp:2601–2810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2599namespace indicators {
2600
2601class IndeterminateProgressBar {
2602 using Settings =
2603 std::tuple<option::BarWidth, option::PrefixText, option::PostfixText, option::Start,
2604 option::End, option::Fill, option::Lead, option::MaxPostfixTextLen,
2605 option::Completed, option::ForegroundColor, option::FontStyles, option::Stream>;
2606
2607 enum class Direction { forward, backward };
2608
2609 Direction direction_{Direction::forward};
2610
2611public:
2612 template <typename... Args,
2613 typename std::enable_if<details::are_settings_from_tuple<
2614 Settings, typename std::decay<Args>::type...>::value,
2615 void *>::type = nullptr>
2616 explicit IndeterminateProgressBar(Args &&... args)
2617 : settings_(details::get<details::ProgressBarOption::bar_width>(option::BarWidth{100},
2618 std::forward<Args>(args)...),
2619 details::get<details::ProgressBarOption::prefix_text>(
2620 option::PrefixText{}, std::forward<Args>(args)...),
2621 details::get<details::ProgressBarOption::postfix_text>(
2622 option::PostfixText{}, std::forward<Args>(args)...),
2623 details::get<details::ProgressBarOption::start>(option::Start{"["},
2624 std::forward<Args>(args)...),
2625 details::get<details::ProgressBarOption::end>(option::End{"]"},
2626 std::forward<Args>(args)...),
2627 details::get<details::ProgressBarOption::fill>(option::Fill{"."},
2628 std::forward<Args>(args)...),
2629 details::get<details::ProgressBarOption::lead>(option::Lead{"<==>"},
2630 std::forward<Args>(args)...),
2631 details::get<details::ProgressBarOption::max_postfix_text_len>(
2632 option::MaxPostfixTextLen{0}, std::forward<Args>(args)...),
2633 details::get<details::ProgressBarOption::completed>(option::Completed{false},
2634 std::forward<Args>(args)...),
2635 details::get<details::ProgressBarOption::foreground_color>(
2636 option::ForegroundColor{Color::unspecified}, std::forward<Args>(args)...),
2637 details::get<details::ProgressBarOption::font_styles>(
2638 option::FontStyles{std::vector<FontStyle>{}}, std::forward<Args>(args)...),
2639 details::get<details::ProgressBarOption::stream>(option::Stream{std::cout},
2640 std::forward<Args>(args)...)) {
2641 // starts with [<==>...........]
2642 // progress_ = 0
2643
2644 // ends with [...........<==>]
2645 // ^^^^^^^^^^^^^^^^^ bar_width
2646 // ^^^^^^^^^^^^ (bar_width - len(lead))
2647 // progress_ = bar_width - len(lead)
2648 progress_ = 0;
2649 max_progress_ = get_value<details::ProgressBarOption::bar_width>() -
2650 get_value<details::ProgressBarOption::lead>().size() +
2651 get_value<details::ProgressBarOption::start>().size() +
2652 get_value<details::ProgressBarOption::end>().size();
2653 }
2654
2655 template <typename T, details::ProgressBarOption id>
2656 void set_option(details::Setting<T, id> &&setting) {
2657 static_assert(!std::is_same<T, typename std::decay<decltype(details::get_value<id>(
2658 std::declval<Settings>()))>::type>::value,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected