ROSE 0.11.145.147
|
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 <Sawyer/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. | |
ProgressBar (ValueType rightValue, const Message::SProxy &stream, const std::string &name="progress") | |
Construct a progress bar incrementing from zero to some limit. | |
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. | |
double | ratio () const |
Value of progress bar as a ratio of completeness clipped between 0 and 1. | |
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. | |
Suffix | suffix () const |
Property: suffix. | |
ProgressBar & | suffix (const Suffix &suffix) |
Property: suffix. | |
std::pair< ValueType, ValueType > | domain () const |
Possible values. | |
void | domain (const std::pair< ValueType, ValueType > &p) |
Possible values. | |
void | domain (ValueType leftValue, ValueType rightValue) |
Possible values. | |
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. | |
void | prefix (const std::string &s) |
String to show before the beginning of the bar. | |
std::pair< char, char > | barchars () const |
Characters to use for the bar. | |
void | barchars (char bar, char nonBar) |
Characters to use for the bar. | |
std::pair< std::string, std::string > | endchars () const |
Characters to use for the left and right ends of the bar. | |
void | endchars (const std::string <, const std::string &rt) |
Characters to use for the left and right ends of the bar. | |
bool | showPercent () const |
Whether to show the percent indication. | |
void | showPercent (bool b) |
Whether to show the percent indication. | |
bool | showValue () const |
Whether to show the current value. | |
void | showValue (bool b) |
Whether to show the current value. | |
typedef S Sawyer::ProgressBar< T, S >::Suffix |
Definition at line 111 of file ProgressBar.h.
typedef T Sawyer::ProgressBar< T, S >::ValueType |
Definition at line 112 of file ProgressBar.h.
|
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 |
Value for the progress bar.
Definition at line 159 of file ProgressBar.h.
Referenced by Rose::BinaryAnalysis::SerialInput::loadObject(), and Rose::BinaryAnalysis::SerialOutput::saveObject().
|
inline |
Value for the progress bar.
Definition at line 163 of file ProgressBar.h.
|
inline |
Value for the progress bar.
Definition at line 169 of file ProgressBar.h.
|
inline |
Value for the progress bar.
Definition at line 176 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 |
True if the distance between the minimum and maximum is zero.
Definition at line 214 of file ProgressBar.h.
|
inline |
True if the minimum value is greater than the maximum value.
Definition at line 220 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.
void Sawyer::ProgressBar< T, S >::increment | ( | ValueType | delta = 1 | ) |
Increment or decrement the progress bar.
Definition at line 415 of file ProgressBar.h.
Referenced by Sawyer::ProgressBar< T, S >::operator++(), Sawyer::ProgressBar< T, S >::operator++(), and Sawyer::ProgressBar< T, S >::operator+=().
void Sawyer::ProgressBar< T, S >::decrement | ( | ValueType | delta = 1 | ) |
Increment or decrement the progress bar.
Definition at line 424 of file ProgressBar.h.
Referenced by Sawyer::ProgressBar< T, S >::operator--(), Sawyer::ProgressBar< T, S >::operator--(), and Sawyer::ProgressBar< T, S >::operator-=().
|
inline |
Increment or decrement the progress bar.
Definition at line 249 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::increment().
|
inline |
Increment or decrement the progress bar.
Definition at line 253 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::increment().
|
inline |
Increment or decrement the progress bar.
Definition at line 257 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::decrement().
|
inline |
Increment or decrement the progress bar.
Definition at line 261 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::decrement().
|
inline |
Increment or decrement the progress bar.
Definition at line 265 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::increment().
|
inline |
Increment or decrement the progress bar.
Definition at line 269 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::decrement().
|
inline |
Width of progress bar in characters at 100%.
Definition at line 277 of file ProgressBar.h.
Referenced by Sawyer::ProgressBar< T, S >::width().
|
inline |
Width of progress bar in characters at 100%.
Definition at line 281 of file ProgressBar.h.
References Sawyer::ProgressBar< T, S >::width().
|
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.
Referenced by Rose::BinaryAnalysis::SerialInput::loadObject(), and Rose::BinaryAnalysis::SerialOutput::saveObject().
|
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 |