STORMM Source Documentation
Loading...
Searching...
No Matches
stormm::reporting::ProgressBar Class Reference

Public Member Functions

 ProgressBar (int cycle_count_in=0, bool show_bar_in=true, std::ostream &output_in=std::cout)
 The constructor for a ProgressBar.
 
const std::string & getState () const
 Get the current state of the progress bar, for inspection.
 
void initialize (int n=0, bool show_bar_in=true, std::ostream &out=std::cout)
 Initializes a new Progress Bar from scratch, taking in user-specified information. To be used when we want to do a hard-refresh on the existing ProgressBar object.
 
void reset ()
 Resets the current instance of the ProgressBar object (sets percentage to 0). To be used before a new loop, with every other setting remaining the same.
 
void setIterations (int iter)
 Set a new number of iterations for an existing ProgressBar object.
 
void setDoneChar (const std::string &sym)
 Set a new "done" char for a ProgressBar object. This is the char that appears when a percentage is done in the ProgressBar.
 
void setTodoChar (const std::string &sym)
 Set a new "todo" char for a ProgressBar object. This is the char that populates the remaining of the ProgressBar object.
 
void setOpeningBracketChar (const std::string &sym)
 Set a new opening bracket for a ProgressBar object. This is the char during the start of a ProgressBar object.
 
void setClosingBracketChar (const std::string &sym)
 Set a new closing bracket for a ProgressBar object. This is the char to use for a closing char of the bar (default is ']')
 
void showBar (bool flag=true)
 Toggles the visibility of the ProgressBar. Default is true.
 
void setOutputStream (std::ostream &stream)
 Function to set the output stream of the current ProgressBar object. Default is cout, can be changed to any std::ostream &object.
 
void setTerminalWidth (int width)
 Allows the user to set a custom terminal width for the ProgressBar. If this function is called, it will override the dynamically inferred width.
 
void allocateBarContents ()
 Function to allocate the bar_contents string for the ProgressBar object. This is called when the bar is first initialized or when the terminal width is changed.
 
void update ()
 Function to update the ProgressBar, incrementing the number of iterations by 1, calculating the appropriate percentage, and rendering the ProgressBar in the terminal.
 

Member Function Documentation

◆ initialize()

void stormm::reporting::ProgressBar::initialize ( int n = 0,
bool show_bar_in = true,
std::ostream & out = std::cout )

Initializes a new Progress Bar from scratch, taking in user-specified information. To be used when we want to do a hard-refresh on the existing ProgressBar object.

Parameters
outDetermines which C standard output stream to use. Default is cout, can use cerr or C++ methods such as printf.

◆ setDoneChar()

void stormm::reporting::ProgressBar::setDoneChar ( const std::string & sym)

Set a new "done" char for a ProgressBar object. This is the char that appears when a percentage is done in the ProgressBar.

Parameters
symThe string to use for a Done char (default is '#')

◆ setIterations()

void stormm::reporting::ProgressBar::setIterations ( int iter)

Set a new number of iterations for an existing ProgressBar object.

Parameters
iterThe new number of iterations for the ProgressBar object

◆ setOpeningBracketChar()

void stormm::reporting::ProgressBar::setOpeningBracketChar ( const std::string & sym)

Set a new opening bracket for a ProgressBar object. This is the char during the start of a ProgressBar object.

Parameters
symThe string to use for an opening char of the bar (default is '[')

◆ setOutputStream()

void stormm::reporting::ProgressBar::setOutputStream ( std::ostream & stream)

Function to set the output stream of the current ProgressBar object. Default is cout, can be changed to any std::ostream &object.

Parameters
streamThe standard output stream to use for rendering the progress bar.

◆ setTerminalWidth()

void stormm::reporting::ProgressBar::setTerminalWidth ( int width)

Allows the user to set a custom terminal width for the ProgressBar. If this function is called, it will override the dynamically inferred width.

Parameters
widthThe new width of the terminal in characters

◆ setTodoChar()

void stormm::reporting::ProgressBar::setTodoChar ( const std::string & sym)

Set a new "todo" char for a ProgressBar object. This is the char that populates the remaining of the ProgressBar object.

Parameters
symThe string to use for a Todo char (default is ' ')

◆ showBar()

void stormm::reporting::ProgressBar::showBar ( bool flag = true)

Toggles the visibility of the ProgressBar. Default is true.

Parameters
flagBoolean value to show/hide the ProgressBar. If hidden, the percentage value is still shown.

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