template<std::size_t N>
tk::Progress class

Simple progress class for outputing progress indicators during a task This is a helper class to abstract away the details of using Print::progress() used to output progress reports to the screen during a task consisting of multiple sub-tasks happening at the same time. The template argument is a compile-time integer which is the number of independent sub-tasks the progress indicator receives messages for and counts them independtly toward multiple maxima.

Constructors, destructors, conversion operators

Progress(bool feedback, const std::array<std::string, N>& prefix, const std::array<std::string, N>& legend, std::array<int, N>&& max = std::array<int, N>()) explicit

Public functions

void start(const Print& print, const std::string& msg)
void start(const Print& print, const std::string& msg, std::array<int, N>&& max)
Start counting sub-tasks outputing an intial task message and set max number of items to be expected per sub-task.
template<std::size_t i>
void inc(const Print& print)
void end(const Print& print)

Function documentation

template<std::size_t N>
tk::Progress<N>::Progress(bool feedback, const std::array<std::string, N>& prefix, const std::array<std::string, N>& legend, std::array<int, N>&& max = std::array<int, N>()) explicit

Parameters
feedback in Whether to send sub-task feedback to host
prefix in Strings to output prefixing the progress report
legend in Legend for each prefix to output at start
max in Array of integers equaling the max number of items to be expected per sub-task

Constructor

template<std::size_t N>
void tk::Progress<N>::start(const Print& print, const std::string& msg)

Parameters
print in Pretty printer object to use for printing progress
msg in Message to output to screen. This message should be descriptive of all the sub-tasks we are responsible for. I.e., this is usually a list of multiple sub-tasks happening at the same time. Appending to msg we also output the legend of subtasks in parentheses.

Start counting sub-tasks outputing an intial task message

template<std::size_t N>
void tk::Progress<N>::start(const Print& print, const std::string& msg, std::array<int, N>&& max)

Start counting sub-tasks outputing an intial task message and set max number of items to be expected per sub-task.

Parameters
print in Pretty printer object to use for printing progress
msg in Message to output to screen. This message should be descriptive of all the sub-tasks we are responsible for. I.e., this is usually a list of multiple sub-tasks happening at the same time.
max in Array of integers equaling the max number of items to be expected per sub-task This function can be used to do the same as start( msg ) and update/reset the max number of items per sub-task in case they are not all yet available when the constructor is called.

template<std::size_t N> template<std::size_t i>
void tk::Progress<N>::inc(const Print& print)

Parameters
print in Pretty printer object to use for printing progress The template argument indexes the sub-task. A compile-time assert emits an error in case it is out of bounds.

Receive an update to a sub-task counter and update progress report

template<std::size_t N>
void tk::Progress<N>::end(const Print& print)

Parameters
print in Pretty printer object to use for printing progress When this function is called, all sub-tasks are assumed to be finished, i.e., assumed to have reached their respective maximum values. Thus we update our 'done' array to be equal to 'max' and output the progress report one final time before outputing 'done'. When this function is called it is possible that not all sub-task counters have reached their maximum, which can happen if the final reduction (if exists), signaling the absolute end of a task (consisting of multiple sub-tasks we count counters for), is scheduled before (or is faster) than as the individual sub-task counting messages arrive. Even if that is the case, this call "officially" finishes all sub-tasks, and outputs the progress report using the max values for all sub-tasks to leave a consistent screen output finishing the task.

Finish progress report updating it one last time