Class ProgressBar

Class Documentation

class ProgressBar

Public Functions

ProgressBar(size_t max_val, string prefix = "")

Ctor.

Parameters:
  • max_val – The number of performed iterations

  • prefix – The prefix string for progress output

virtual ~ProgressBar()
void operator++()

Increases the counter of performed iterations.

void operator+=(size_t n)

Increases the counter of performed by n.

Public Static Functions

static void setProgressCallback(ProgressCallbackPtr)

Registers a callback that is called with the new value when the percentage of the progress changed.

Param :

static void setProgressTitleCallback(ProgressTitleCallbackPtr)

Registers a callback that is called when a new progress instance is created.

Param :

Protected Functions

void print_bar()

Prints the output.

Protected Attributes

string m_prefix

The prefix string.

size_t m_maxVal

The number of iterations.

size_t m_currentVal

The current counter.

boost::mutex m_mutex

A mutex object for counter increment (for parallel executions)

int m_percent

The current progress in percent.

std::chrono::time_point<std::chrono::system_clock> m_start

The starting time of the progress bar.

stringstream m_stream

A string stream for output generation.

string m_fillstring

A fill string for correct output alignment.

Protected Static Attributes

static ProgressCallbackPtr m_progressCallback
static ProgressTitleCallbackPtr m_titleCallback