vSMC  v3.0.0
Scalable Monte Carlo
Public Member Functions | List of all members
vsmc::Progress Class Reference

Display a progress bar while algorithm proceed. More...

#include <vsmc/utility/progress.hpp>

Public Member Functions

 Progress (std::ostream &os=std::cout)
 Construct a Progress with an output stream. More...
 
 Progress (const Progress &other)=delete
 
 ~Progress ()
 
void increment (std::size_t step=1)
 Increment the iteration count. More...
 
void message (const std::string &msg)
 Set a new message for display. More...
 
Progressoperator= (const Progress &other)=delete
 
void start (std::size_t total, const std::string &msg=std::string(), std::size_t length=0, bool show_iter=true, double interval_s=0.1)
 Start to print the progress. More...
 
void stop (bool finished=true)
 Stop to print the progress. More...
 

Detailed Description

Display a progress bar while algorithm proceed.

Definition at line 43 of file progress.hpp.

Constructor & Destructor Documentation

vsmc::Progress::Progress ( std::ostream &  os = std::cout)
inline

Construct a Progress with an output stream.

Definition at line 47 of file progress.hpp.

vsmc::Progress::Progress ( const Progress other)
delete
vsmc::Progress::~Progress ( )
inline

Definition at line 72 of file progress.hpp.

Member Function Documentation

void vsmc::Progress::increment ( std::size_t  step = 1)
inline

Increment the iteration count.

This member function is thread-safe, and can be called from multiple threads.

Definition at line 117 of file progress.hpp.

void vsmc::Progress::message ( const std::string &  msg)
inline

Set a new message for display.

Definition at line 120 of file progress.hpp.

Progress& vsmc::Progress::operator= ( const Progress other)
delete
void vsmc::Progress::start ( std::size_t  total,
const std::string &  msg = std::string(),
std::size_t  length = 0,
bool  show_iter = true,
double  interval_s = 0.1 
)
inline

Start to print the progress.

Parameters
totalTotal amount of work represented by an integer, for example file size or SMC algorithm total number of iterations
msgA (short) discreptive message
lengthThe length of the progress bar between brackets. If it is zero, then no bar is displayed at all
show_iterShall the iteration count be displayed.
interval_sThe sleep interval in seconds

Definition at line 83 of file progress.hpp.

void vsmc::Progress::stop ( bool  finished = true)
inline

Stop to print the progress.

Parameters
finishedIf true, then it is assumed that all work has been finished, and at the end the progress will be shown as 100% and total/total, where total is the first parameter of start. Otherwise, whatever progress has been made will be shown.

Definition at line 103 of file progress.hpp.