HIPO  4.3.0
High Performance Output data format for experimental physics
ProgressTracker Class Reference

Thread-safe progress tracker with visual progress bar. More...

#include <progresstracker.hpp>

Classes

struct  Config
 Configuration settings for progress bar display. More...
 

Public Member Functions

 ProgressTracker (std::size_t total, Config config={})
 Constructs a progress tracker. More...
 
 ~ProgressTracker () noexcept
 
 ProgressTracker (const ProgressTracker &)=delete
 
ProgressTrackeroperator= (const ProgressTracker &)=delete
 
 ProgressTracker (ProgressTracker &&) noexcept
 
ProgressTrackeroperator= (ProgressTracker &&) noexcept
 
auto increment () noexcept -> void
 Increments the progress counter (thread-safe, no immediate display update). More...
 
auto add (std::size_t count) noexcept -> void
 Adds multiple items to progress (thread-safe, no immediate display update). More...
 
auto get_processed () const noexcept -> std::size_t
 Gets current progress count (thread-safe). More...
 
auto get_total () const noexcept -> std::size_t
 Gets total item count (thread-safe). More...
 
auto get_progress () const noexcept -> double
 Gets current progress ratio [0.0, 1.0] (thread-safe). More...
 
auto start () noexcept -> void
 Starts the background update thread and shows initial display. More...
 
auto finish () noexcept -> void
 Stops the update thread and displays final completion message. More...
 

Static Public Member Functions

static auto clear_line () noexcept -> void
 Clears the current progress line. More...
 
static auto format_duration (std::chrono::seconds duration) noexcept -> std::string
 Formats a duration given in seconds into a human-readable string. More...
 

Detailed Description

Thread-safe progress tracker with visual progress bar.

Definition at line 37 of file progresstracker.hpp.

Constructor & Destructor Documentation

◆ ProgressTracker() [1/3]

ProgressTracker::ProgressTracker ( std::size_t  total,
Config  config = {} 
)
inlineexplicit

Constructs a progress tracker.

Parameters
totalTotal number of items to track
configDisplay configuration
Exceptions
std::invalid_argumentif total is 0

Definition at line 210 of file progresstracker.hpp.

◆ ~ProgressTracker()

ProgressTracker::~ProgressTracker ( )
inlinenoexcept

Definition at line 215 of file progresstracker.hpp.

◆ ProgressTracker() [2/3]

ProgressTracker::ProgressTracker ( const ProgressTracker )
delete

◆ ProgressTracker() [3/3]

ProgressTracker::ProgressTracker ( ProgressTracker &&  other)
inlinenoexcept

Definition at line 220 of file progresstracker.hpp.

Member Function Documentation

◆ add()

auto ProgressTracker::add ( std::size_t  count) -> void
inlinenoexcept

Adds multiple items to progress (thread-safe, no immediate display update).

Definition at line 247 of file progresstracker.hpp.

◆ clear_line()

auto ProgressTracker::clear_line ( ) -> void
inlinestaticnoexcept

Clears the current progress line.

Definition at line 299 of file progresstracker.hpp.

◆ finish()

auto ProgressTracker::finish ( ) -> void
inlinenoexcept

Stops the update thread and displays final completion message.

Definition at line 500 of file progresstracker.hpp.

◆ format_duration()

auto ProgressTracker::format_duration ( std::chrono::seconds  duration) -> std::string
inlinestaticnoexcept

Formats a duration given in seconds into a human-readable string.

Converts the provided std::chrono::seconds duration into a string representation, typically in the format "HH:MM:SS" or similar, for display purposes.

Parameters
durationThe duration to format, expressed as std::chrono::seconds.
Returns
A std::string containing the formatted duration.
Note
This function does not throw exceptions.

Definition at line 278 of file progresstracker.hpp.

◆ get_processed()

auto ProgressTracker::get_processed ( ) const -> std::size_t
inlinenoexcept

Gets current progress count (thread-safe).

Definition at line 88 of file progresstracker.hpp.

◆ get_progress()

auto ProgressTracker::get_progress ( ) const -> double
inlinenoexcept

Gets current progress ratio [0.0, 1.0] (thread-safe).

Definition at line 251 of file progresstracker.hpp.

◆ get_total()

auto ProgressTracker::get_total ( ) const -> std::size_t
inlinenoexcept

Gets total item count (thread-safe).

Definition at line 95 of file progresstracker.hpp.

◆ increment()

auto ProgressTracker::increment ( ) -> void
inlinenoexcept

Increments the progress counter (thread-safe, no immediate display update).

Definition at line 243 of file progresstracker.hpp.

◆ operator=() [1/2]

ProgressTracker& ProgressTracker::operator= ( const ProgressTracker )
delete

◆ operator=() [2/2]

ProgressTracker & ProgressTracker::operator= ( ProgressTracker &&  other)
inlinenoexcept

Definition at line 226 of file progresstracker.hpp.

◆ start()

auto ProgressTracker::start ( ) -> void
inlinenoexcept

Starts the background update thread and shows initial display.

Definition at line 485 of file progresstracker.hpp.


The documentation for this class was generated from the following file: