EDoc::ProgressBar Class Reference

#include <include/EDoc/ProgressBar.h>

Inheritance diagram for EDoc::ProgressBar:

EDoc::ProgressIFace< T >

Detailed Description

Displays a percentage progress bar as a bar of '=' characters across the screen.

This has two configurations:

  1. Interactive
  2. Non Interactive
The interactive varient will display a "spinner" in addition to the '=' characters that updates regulary. This requires a terminal as otherwise of exporting output to a file it will contain a number of back-space characters.

Definition at line 41 of file ProgressBar.h.

Public Member Functions

 ProgressBar (bool enable_spinner_in=false, int width_in=DEFAULT_SCREEN_WIDTH, std::string spin_sequence_in=DEFAULT_SPIN_SEQUENCE)
 Create a new progress bar instance.
void Reset ()
 Resets the progress bar to start displaying progress again from 0.
virtual void Start (size_t total)
 See FunctionProgressIFace::Start().
virtual void Progress (Function *data)
 See FunctionProgressIFace::Progress().
virtual void Progress (T *data)=0
 Called each time some progress is made that is to be shown to the user.

Static Public Attributes

static const char * DEFAULT_SPIN_SEQUENCE
 This is the default spin sequence for the spinner.
static const int DEFAULT_SCREEN_WIDTH = 80
 This is the default screen width to use.

Private Attributes

bool enable_spinner
 True if spinner is enabled.
int width
 The width of the terminal to assume.
std::string spin_sequence
 The equence of characters to display when incrementing the progres for a spinner.
int bars
 Current number of bars being displayed.
int spin_index
 Current index for the spinner.
size_t total
size_t current


Constructor & Destructor Documentation

EDoc::ProgressBar::ProgressBar ( bool  enable_spinner_in = false,
int  width_in = DEFAULT_SCREEN_WIDTH,
std::string  spin_sequence_in = DEFAULT_SPIN_SEQUENCE 
)

Create a new progress bar instance.

Parameters:
enable_spinner_in When in iteractive mode this is enabled and displays a spinner when any progress is made.
width_in The width to assume the terminal width is.
spin_sequence_in The spin sequence to use if enable_spinner_in is true.

Definition at line 31 of file ProgressBar.cpp.

References Reset().


Member Function Documentation

EDoc::ProgressBar::Reset (  ) 

Resets the progress bar to start displaying progress again from 0.

Note:
EDoc++ data included.

Definition at line 41 of file ProgressBar.cpp.

References bars, and spin_index.

Referenced by ProgressBar().

EDoc::ProgressBar::Start ( size_t  total  )  [virtual]

See FunctionProgressIFace::Start().

Note:
EDoc++ data included.

Implements EDoc::ProgressIFace< T >.

Definition at line 47 of file ProgressBar.cpp.

References current, and total.

EDoc::ProgressBar::Progress ( EDoc::Function data  )  [virtual]

See FunctionProgressIFace::Progress().

Note:
EDoc++ data included.

Definition at line 53 of file ProgressBar.cpp.

References bars, current, enable_spinner, spin_index, spin_sequence, total, and width.

template<typename T>
virtual void EDoc::ProgressIFace< T >::Progress ( T *  data  )  [pure virtual, inherited]

Called each time some progress is made that is to be shown to the user.

Note: This must be called exactly total number of times, where total is the value passed to the Start() function.

Referenced by EDoc::Dictionary::GenerateExceptions().


Field Documentation

const char * EDoc::ProgressBar::DEFAULT_SPIN_SEQUENCE [static]

This is the default spin sequence for the spinner.

It is a sequence of characters to display when the progress indication increases.

Definition at line 51 of file ProgressBar.h.

const int EDoc::ProgressBar::DEFAULT_SCREEN_WIDTH = 80 [static]

This is the default screen width to use.

Todo:
Find a way of getting the current terminal width so we do not make assumptions.

Definition at line 59 of file ProgressBar.h.

bool EDoc::ProgressBar::enable_spinner [private]

True if spinner is enabled.

Definition at line 101 of file ProgressBar.h.

Referenced by Progress().

int EDoc::ProgressBar::width [private]

The width of the terminal to assume.

Definition at line 106 of file ProgressBar.h.

Referenced by Progress().

std::string EDoc::ProgressBar::spin_sequence [private]

The equence of characters to display when incrementing the progres for a spinner.

Definition at line 112 of file ProgressBar.h.

Referenced by Progress().

int EDoc::ProgressBar::bars [private]

Current number of bars being displayed.

Definition at line 117 of file ProgressBar.h.

Referenced by Progress(), and Reset().

int EDoc::ProgressBar::spin_index [private]

Current index for the spinner.

This determines which character to display next from the spin_sequence.

Definition at line 123 of file ProgressBar.h.

Referenced by Progress(), and Reset().

size_t EDoc::ProgressBar::total [private]

Definition at line 125 of file ProgressBar.h.

Referenced by Progress(), and Start().

size_t EDoc::ProgressBar::current [private]

Definition at line 126 of file ProgressBar.h.

Referenced by Progress(), and Start().


The documentation for this class was generated from the following files:
Generated on Tue Jan 20 18:26:09 2009 for EDoc-0.2.1 by  doxygen 1.5.1