STORMM Source Documentation
Loading...
Searching...
No Matches
progress_bar.h
1// -*-c++-*-
2#ifndef STORMM_PROGRESSBAR_H
3#define STORMM_PROGRESSBAR_H
4
5#include <iostream>
6#include <ostream>
7#include <string>
8#include <stdexcept>
9
10namespace stormm {
11namespace reporting {
12
14public:
16 ProgressBar(int cycle_count_in = 0, bool show_bar_in = true,
17 std::ostream &output_in = std::cout);
18
20 const std::string& getState() const;
21
27 void initialize(int n = 0, bool show_bar_in = true, std::ostream &out = std::cout);
28
31 void reset();
32
36 void setIterations(int iter);
37
42 void setDoneChar(const std::string &sym);
43
48 void setTodoChar(const std::string &sym);
49
54 void setOpeningBracketChar(const std::string &sym);
55
58 void setClosingBracketChar(const std::string &sym);
59
64 void showBar(bool flag = true);
65
70 void setOutputStream(std::ostream &stream);
71
76 void setTerminalWidth(int width);
77
82
86 void update();
87
88private:
89
90 int progress;
92 int cycle_count;
94 int last_percent;
95 bool show_bar;
97 bool update_called;
99 std::string finished_mark;
100 std::string todo_mark;
101 std::string prgb_open_bracket;
102 std::string prgb_close_bracket;
103 std::ostream* output;
104 int terminal_width;
105 std::string bar_contents;
110
113 void updateTerminalWidth();
114};
115
116} // namespace reporting
117} // namespace stormm
118
119#endif // STORMM_PROGRESSBAR_H
120
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 do...
Definition progress_bar.cpp:64
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....
Definition progress_bar.cpp:34
void setOutputStream(std::ostream &stream)
Function to set the output stream of the current ProgressBar object. Default is cout,...
Definition progress_bar.cpp:89
void update()
Function to update the ProgressBar, incrementing the number of iterations by 1, calculating the appro...
Definition progress_bar.cpp:139
void setIterations(int iter)
Set a new number of iterations for an existing ProgressBar object.
Definition progress_bar.cpp:56
void showBar(bool flag=true)
Toggles the visibility of the ProgressBar. Default is true.
Definition progress_bar.cpp:84
void allocateBarContents()
Function to allocate the bar_contents string for the ProgressBar object. This is called when the bar ...
Definition progress_bar.cpp:104
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...
Definition progress_bar.cpp:79
void reset()
Resets the current instance of the ProgressBar object (sets percentage to 0). To be used before a new...
Definition progress_bar.cpp:49
void setOpeningBracketChar(const std::string &sym)
Set a new opening bracket for a ProgressBar object. This is the char during the start of a ProgressBa...
Definition progress_bar.cpp:74
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 ...
Definition progress_bar.cpp:69
void setTerminalWidth(int width)
Allows the user to set a custom terminal width for the ProgressBar. If this function is called,...
Definition progress_bar.cpp:94
const std::string & getState() const
Get the current state of the progress bar, for inspection.
Definition progress_bar.cpp:29
ProgressBar(int cycle_count_in=0, bool show_bar_in=true, std::ostream &output_in=std::cout)
The constructor for a ProgressBar.
Definition progress_bar.cpp:14