25 #ifndef __CONSOLE_PROGRESS_HH__
26 #define __CONSOLE_PROGRESS_HH__
32 #include <Base/Debug/Error.hh>
63 percentageShown_(0), maxValue_(0)
76 void Reset(
unsigned int maxValue = 0)
97 BIASASSERT(curValue <= maxValue_)
99 const float curPercentage =
100 (maxValue_ > 0 ? float(curValue) / float(maxValue_) * 100.0f : 0.0f);
101 const unsigned int curPercRounded = (
unsigned int)(curPercentage + 0.5f);
103 if (curPercentage >= percentageShown_) {
105 if (curPercRounded < 10) {
108 if (curPercRounded < 100) {
111 std::cout << curPercRounded <<
"% " << std::flush;
113 percentageShown_ = curPercRounded + 1;
126 BIASASSERT(curValue <= maxValue_);
128 const float curPercentage =
129 (maxValue_ > 0 ? float(curValue) / float(maxValue_) * 100.0f : 0.0f);
130 const unsigned int curPercRounded = (
unsigned int)(curPercentage + 0.5f);
132 if (curPercentage >= percentageShown_) {
134 const float step = 100.0f / (float) size;
136 for (
unsigned int i = 0; i < size; i++, perc += step) {
137 std::cout << (perc < curPercentage ?
"=" :
" ");
139 std::cout <<
"] " << curPercRounded <<
"% " << std::flush;
141 percentageShown_ = curPercRounded + 1;
148 unsigned int percentageShown_;
151 unsigned int maxValue_;
155 #endif // __CONSOLE_PROGRESS_HH__
void PrintProgressBar(unsigned int curValue, unsigned int size=25)
Prints progress bar showing the current percentage.
Visualises the progress of some computation in the console.
void PrintPercentage(unsigned int curValue)
Prints the current percentage if it is equal or greater than all integral percentage values that have...
ConsoleProgress(unsigned int maxValue=0)
Constructor.
void Reset(unsigned int maxValue=0)
Resets the internal counter and sets the maximum value to reach.