CoreNEURON
|
progressbar – a C class (by convention) for displaying progress on the command line (to stdout).
Definition in file progressbar.cpp.
#include "coreneuron/utils/progressbar/progressbar.hpp"
#include <cassert>
#include <cstddef>
#include <climits>
#include <unistd.h>
Go to the source code of this file.
Classes | |
struct | progressbar_time_components |
Models a duration of time broken into hour/minute/second components. More... | |
Enumerations | |
enum | { DEFAULT_SCREEN_WIDTH = 80 } |
How wide we assume the screen is if termcap fails. More... | |
enum | { MINIMUM_BAR_WIDTH = 10 } |
The smallest that the bar can ever be (not including borders) More... | |
enum | { ETA_FORMAT_LENGTH = 13 } |
The maximum number of characters that the ETA_FORMAT can ever yield. More... | |
enum | { WHITESPACE_LENGTH = 2 } |
Amount of screen width taken up by whitespace (i.e. whitespace between label/bar/ETA components) More... | |
enum | { BAR_BORDER_WIDTH = 2 } |
The amount of width taken up by the border of the bar component. More... | |
enum | { BAR_DRAW_COUNT_MAX = 500 } |
The maximum number of bar redraws (to avoid frequent output in long runs) More... | |
enum | { BAR_DRAW_INTERVAL = 1, BAR_DRAW_INTERVAL_NOTTY = 5 } |
Functions | |
static void | progressbar_draw (const progressbar *bar) |
static int | progressbar_remaining_seconds (const progressbar *bar) |
progressbar * | progressbar_new_with_format (const char *label, unsigned long max, const char *format) |
Create a new progress bar with the specified label, max number of steps, and format string. More... | |
progressbar * | progressbar_new (const char *label, unsigned long max) |
Create a new progress bar with the specified label and max number of steps. More... | |
void | progressbar_update_label (progressbar *bar, const char *label) |
Set the label of the progressbar. More... | |
void | progressbar_free (progressbar *bar) |
Delete an existing progress bar. More... | |
void | progressbar_update (progressbar *bar, unsigned long value, double t) |
Increment an existing progressbar by value steps. More... | |
void | progressbar_inc (progressbar *bar, double t) |
Increment an existing progressbar by a single step. More... | |
static void | progressbar_write_char (FILE *file, const int ch, const size_t times) |
static int | progressbar_max (int x, int y) |
static unsigned int | get_screen_width (void) |
static int | progressbar_bar_width (int screen_width, int label_length) |
static int | progressbar_label_width (int screen_width, int label_length, int bar_width) |
static progressbar_time_components | progressbar_calc_time_components (int seconds) |
void | progressbar_finish (progressbar *bar) |
Finish a progressbar, indicating 100% completion, and free it. More... | |
Variables | |
static const char *const | ETA_FORMAT = "t: %-6.2f ETA:%2dh%02dm%02ds" |
The format in which the estimated remaining time will be reported. More... | |
anonymous enum |
How wide we assume the screen is if termcap fails.
Enumerator | |
---|---|
DEFAULT_SCREEN_WIDTH |
Definition at line 20 of file progressbar.cpp.
anonymous enum |
The smallest that the bar can ever be (not including borders)
Enumerator | |
---|---|
MINIMUM_BAR_WIDTH |
Definition at line 23 of file progressbar.cpp.
anonymous enum |
The maximum number of characters that the ETA_FORMAT can ever yield.
Enumerator | |
---|---|
ETA_FORMAT_LENGTH |
Definition at line 29 of file progressbar.cpp.
anonymous enum |
Amount of screen width taken up by whitespace (i.e. whitespace between label/bar/ETA components)
Enumerator | |
---|---|
WHITESPACE_LENGTH |
Definition at line 32 of file progressbar.cpp.
anonymous enum |
The amount of width taken up by the border of the bar component.
Enumerator | |
---|---|
BAR_BORDER_WIDTH |
Definition at line 35 of file progressbar.cpp.
anonymous enum |
The maximum number of bar redraws (to avoid frequent output in long runs)
Enumerator | |
---|---|
BAR_DRAW_COUNT_MAX |
Definition at line 38 of file progressbar.cpp.
anonymous enum |
Enumerator | |
---|---|
BAR_DRAW_INTERVAL | |
BAR_DRAW_INTERVAL_NOTTY |
Definition at line 40 of file progressbar.cpp.
|
static |
Definition at line 163 of file progressbar.cpp.
|
static |
Definition at line 167 of file progressbar.cpp.
|
static |
Definition at line 192 of file progressbar.cpp.
|
static |
Definition at line 202 of file progressbar.cpp.
void progressbar_finish | ( | progressbar * | bar | ) |
Finish a progressbar, indicating 100% completion, and free it.
Finalize (and free!) a progressbar.
Definition at line 245 of file progressbar.cpp.
void progressbar_free | ( | progressbar * | bar | ) |
Delete an existing progress bar.
Free an existing progress bar. Don't call this directly; call progressbar_finish instead.
Definition at line 99 of file progressbar.cpp.
void progressbar_inc | ( | progressbar * | bar, |
double | t | ||
) |
Increment an existing progressbar by a single step.
Increment the given progressbar. Don't increment past the initialized # of steps, though.
Definition at line 149 of file progressbar.cpp.
|
static |
Definition at line 172 of file progressbar.cpp.
|
static |
Definition at line 159 of file progressbar.cpp.
progressbar* progressbar_new | ( | const char * | label, |
unsigned long | max | ||
) |
Create a new progress bar with the specified label and max number of steps.
Create a new progressbar with the specified label and number of steps.
Definition at line 88 of file progressbar.cpp.
progressbar* progressbar_new_with_format | ( | const char * | label, |
unsigned long | max, | ||
const char * | format | ||
) |
Create a new progress bar with the specified label, max number of steps, and format string.
Create a new progressbar with the specified label, number of steps, and format string.
Note that format
must be exactly three characters long, e.g. "<->" to render a progress bar like "<---------->". Returns nullptr if there isn't enough memory to allocate a progressbar
Definition at line 60 of file progressbar.cpp.
|
static |
Definition at line 183 of file progressbar.cpp.
void progressbar_update | ( | progressbar * | bar, |
unsigned long | value, | ||
double | t | ||
) |
Increment an existing progressbar by value
steps.
Set the current status on the given progressbar.
Additionally issues a redraw in case a certain time interval has elapsed (min: 1sec) Reasons for a larger interval are:
Definition at line 110 of file progressbar.cpp.
void progressbar_update_label | ( | progressbar * | bar, |
const char * | label | ||
) |
Set the label of the progressbar.
Note that no rendering is done. The label is simply set so that the next rendering will use the new label. To immediately see the new label, call progressbar_draw. Does not update display or copy the label
Definition at line 92 of file progressbar.cpp.
|
static |
Definition at line 153 of file progressbar.cpp.
|
static |
The format in which the estimated remaining time will be reported.
Definition at line 26 of file progressbar.cpp.