ROSE
0.11.96.11
|
Progress bars.
Progress bars are fully integrated with the Sawyer logging system so that they behave with respect to other messages.
Example usage:
The progress bar is created with a name and capacity. As the progress bar is incremented the bar will increase. Messages printed while the progress bar is active do not interfere with the progress bar. When the progress bar object is destroyed the progress bar disappears.
Progress bars should be output to the MARCH
stream rather than INFO
. If all progress bars follow this policy then it's easy to enable or disable them without affecting other diagnostic output.
The entire progress bar public interface is synchronized–it can be called from multiple threads all accessing the same object and their operations will be serialized.
Definition at line 109 of file ProgressBar.h.
#include <ProgressBar.h>
Public Types | |
typedef S | Suffix |
typedef T | ValueType |
Public Member Functions | |
ProgressBar (const Message::SProxy &stream, const std::string &name="progress") | |
Construct spinning progress bar. More... | |
ProgressBar (ValueType rightValue, const Message::SProxy &stream, const std::string &name="progress") | |
Construct a progress bar incrementing from zero to some limit. More... | |
ProgressBar (ValueType leftValue, ValueType curValue, ValueType rightValue, const Message::SProxy &stream, const std::string &name="progress") | |
Construct a progress bar with left and right limits. More... | |
double | ratio () const |
Value of progress bar as a ratio of completeness clipped between 0 and 1. More... | |
bool | isEmpty () const |
True if the distance between the minimum and maximum is zero. | |
bool | isBackward () const |
True if the minimum value is greater than the maximum value. | |
ValueType | value () const |
Value for the progress bar. | |
void | value (ValueType curValue) |
Value for the progress bar. | |
void | value (ValueType curValue, ValueType rightValue) |
Value for the progress bar. | |
void | value (ValueType leftValue, ValueType curValue, ValueType rightValue) |
Value for the progress bar. | |
Suffix | suffix () |
Property: suffix. More... | |
Suffix | suffix () const |
Property: suffix. More... | |
ProgressBar & | suffix (const Suffix &suffix) |
Property: suffix. More... | |
std::pair< ValueType, ValueType > | domain () const |
Possible values. More... | |
void | domain (const std::pair< ValueType, ValueType > &p) |
Possible values. More... | |
void | domain (ValueType leftValue, ValueType rightValue) |
Possible values. More... | |
void | increment (ValueType delta=1) |
Increment or decrement the progress bar. | |
void | decrement (ValueType delta=1) |
Increment or decrement the progress bar. | |
ProgressBar & | operator++ () |
Increment or decrement the progress bar. | |
ProgressBar & | operator++ (int) |
Increment or decrement the progress bar. | |
ProgressBar & | operator-- () |
Increment or decrement the progress bar. | |
ProgressBar & | operator-- (int) |
Increment or decrement the progress bar. | |
ProgressBar & | operator+= (ValueType delta) |
Increment or decrement the progress bar. | |
ProgressBar & | operator-= (ValueType delta) |
Increment or decrement the progress bar. | |
size_t | width () const |
Width of progress bar in characters at 100%. | |
void | width (size_t width) |
Width of progress bar in characters at 100%. | |
const std::string & | prefix () const |
String to show before the beginning of the bar. More... | |
void | prefix (const std::string &s) |
String to show before the beginning of the bar. More... | |
std::pair< char, char > | barchars () const |
Characters to use for the bar. More... | |
void | barchars (char bar, char nonBar) |
Characters to use for the bar. More... | |
std::pair< std::string, std::string > | endchars () const |
Characters to use for the left and right ends of the bar. More... | |
void | endchars (const std::string <, const std::string &rt) |
Characters to use for the left and right ends of the bar. More... | |
bool | showPercent () const |
Whether to show the percent indication. More... | |
void | showPercent (bool b) |
Whether to show the percent indication. More... | |
bool | showValue () const |
Whether to show the current value. More... | |
void | showValue (bool b) |
Whether to show the current value. More... | |
|
inlineexplicit |
Construct spinning progress bar.
A progress bar without a capacity results in a "spinner" that moves back and forth instead of a 0 to 100% bar. This kind of progress bar can be used when the number of iterations to complete a task is unknown.
Definition at line 133 of file ProgressBar.h.
|
inline |
Construct a progress bar incrementing from zero to some limit.
The progress bar is initialized to zero and constructed so that when the value reaches rightValue
the bar will read 100%.
Definition at line 141 of file ProgressBar.h.
|
inline |
Construct a progress bar with left and right limits.
The progress bar is set so that leftValue
represents the zero percent point and rightValue represents the 100% point. The curValue
is the current value of the progress bar, which need not be between the the limits (the percent indications will be clipped the the specified interval).
Definition at line 150 of file ProgressBar.h.
|
inline |
Property: suffix.
This user-defined object provides the suffix for the progress bar. It will be appended to the progress bar string with the std::ostream
's <<
operator. It should not contain any line feeds.
Definition at line 190 of file ProgressBar.h.
Referenced by Sawyer::ProgressBar< T, S >::suffix().
|
inline |
Property: suffix.
This user-defined object provides the suffix for the progress bar. It will be appended to the progress bar string with the std::ostream
's <<
operator. It should not contain any line feeds.
Definition at line 194 of file ProgressBar.h.
|
inline |
Property: suffix.
This user-defined object provides the suffix for the progress bar. It will be appended to the progress bar string with the std::ostream
's <<
operator. It should not contain any line feeds.
Definition at line 198 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::suffix().
|
inline |
Value of progress bar as a ratio of completeness clipped between 0 and 1.
A progress bar that is backward (min value is greater than max value) also returns a value between zero and one, and also is a measurement of how far the progress bar should be drawn from the left side toward the right.
Definition at line 208 of file ProgressBar.h.
|
inline |
Possible values.
These indicate the zero and 100% end points.
Definition at line 227 of file ProgressBar.h.
|
inline |
Possible values.
These indicate the zero and 100% end points.
Definition at line 231 of file ProgressBar.h.
|
inline |
Possible values.
These indicate the zero and 100% end points.
Definition at line 237 of file ProgressBar.h.
|
inline |
String to show before the beginning of the bar.
This should be something very short, like "processing input".
Definition at line 290 of file ProgressBar.h.
|
inline |
String to show before the beginning of the bar.
This should be something very short, like "processing input".
Definition at line 294 of file ProgressBar.h.
|
inline |
Characters to use for the bar.
The first is from zero to the current ratio() and the second is the character with which to fill the rest of the bar's area. The defaults are '#' and '-'.
Definition at line 304 of file ProgressBar.h.
|
inline |
Characters to use for the bar.
The first is from zero to the current ratio() and the second is the character with which to fill the rest of the bar's area. The defaults are '#' and '-'.
Definition at line 308 of file ProgressBar.h.
|
inline |
Characters to use for the left and right ends of the bar.
The default is '[' and ']'.
Definition at line 318 of file ProgressBar.h.
|
inline |
Characters to use for the left and right ends of the bar.
The default is '[' and ']'.
Definition at line 322 of file ProgressBar.h.
|
inline |
Whether to show the percent indication.
The default is true.
Definition at line 332 of file ProgressBar.h.
|
inline |
Whether to show the percent indication.
The default is true.
Definition at line 336 of file ProgressBar.h.
|
inline |
|
inline |