Marine systems simulation
ProgressBar Class Reference

#include <CProgressBar.h>

Public Member Functions

 ProgressBar (double totalTime, const std::string &initialMessage="")
 
 ~ProgressBar ()
 
 ProgressBar (const ProgressBar &o)=delete
 
ProgressBaroperator= (const ProgressBar &o)=delete
 
void endProgressBar ()
 
void printNewMessage (const std::string &message)
 
void setTime (double currentTime)
 

Static Public Member Functions

static std::string generateProgressBar (unsigned int percentage, double currentTime)
 

Static Public Attributes

static int LENGTH_OF_PROGRESS_BAR
 
static double PERCENTAGE_BIN_SIZE
 

Detailed Description

Constructor & Destructor Documentation

◆ ProgressBar()

ProgressBar::ProgressBar ( double  totalTime,
const std::string &  initialMessage = "" 
)
inline

Constructor. It takes two values: the expected number of iterations whose progress we want to monitor and an initial message to be displayed on top of the bar (which can be updated with updateLastPrintedMessage()).

◆ ~ProgressBar()

ProgressBar::~ProgressBar ( )
inline

Destructor to guarantee RAII.

Member Function Documentation

◆ endProgressBar()

void ProgressBar::endProgressBar ( )
inline

Must be invoked when the progress bar is no longer needed to restore the position of the cursor to the end of the output. It is automatically invoked when the object is destroyed.

◆ printNewMessage()

void ProgressBar::printNewMessage ( const std::string &  message)
inline

Prints a new message under the last printed message, without overwriting it. This moves the progress bar down to be placed under the newly written message.

◆ setTime()

void ProgressBar::setTime ( double  currentTime)
inline

Prints a message while the progress bar is on the screen on top on the last printed message. Since the cursor is right at the beginning of the progress bar, it moves the cursor up by one line before printing, and then returns it to its original position.


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