CEDRIC  Revision_backup-2009-02
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ProgressIndicator Class Referenceabstract

Interface for a polling-based progress indicator (e.g. progress bar) More...

#include <ProgressIndicator.h>

Inheritance diagram for ProgressIndicator:
ConsoleProgressIndicator GlobalProgressIndicator

Public Member Functions

 ProgressIndicator (int min=0, int max=100)
 
virtual ~ProgressIndicator ()
 
bool poll (int progress)
 
void start ()
 
void finish ()
 
void step ()
 
void setRange (int min, int max)
 
virtual void setTitle (const std::string &title)
 
virtual void setLabel (const std::string &label)
 
float percentage () const
 
bool wasCanceled () const
 
int progress () const
 
int minValue () const
 
int maxValue () const
 
std::string title () const
 
std::string & title ()
 
std::string label () const
 
std::string & label ()
 

Protected Member Functions

virtual bool onPoll ()=0
 
virtual void onStart ()=0
 
virtual void onFinish ()=0
 
virtual void onRangeChange (int, int)
 

Protected Attributes

int m_progress
 
bool m_canceled
 
int m_minValue
 
int m_maxValue
 
std::string m_title
 
std::string m_label
 

Detailed Description

Interface for a polling-based progress indicator (e.g. progress bar)

A ProgressIndicator can be used as a commucation channel between a program part which does heavy calculations (like loading huge files from disk) and some kind of main program which handles the gui. It uses a single threaded polling mechanism, where it is thought to derives this class and implement following functions

It is up to the processing task to poll the ProgressIndicator periodically and check isCanceled() to see if he should stop his operation. To make the progress indicator work the loading process must call setRange() to set the progress indicator up and then start() and finish() before the first and after his last call to poll().

Author
Max Hermann <mhermann[at]mail.cern.ch>

Constructor & Destructor Documentation

ProgressIndicator::ProgressIndicator ( int  min = 0,
int  max = 100 
)
inline
virtual ProgressIndicator::~ProgressIndicator ( )
inlinevirtual

Member Function Documentation

void ProgressIndicator::finish ( )
inline
std::string ProgressIndicator::label ( ) const
inline
std::string& ProgressIndicator::label ( )
inline

References m_label.

int ProgressIndicator::maxValue ( ) const
inline

References m_maxValue.

int ProgressIndicator::minValue ( ) const
inline

References m_minValue.

Referenced by GlobalProgressIndicator::onStart().

virtual void ProgressIndicator::onFinish ( )
protectedpure virtual

Implemented in ConsoleProgressIndicator, and GlobalProgressIndicator.

Referenced by finish().

virtual bool ProgressIndicator::onPoll ( )
protectedpure virtual
Returns
Returns false if user canceled, true otherwise

Implemented in ConsoleProgressIndicator, and GlobalProgressIndicator.

Referenced by poll().

virtual void ProgressIndicator::onRangeChange ( int  ,
int   
)
inlineprotectedvirtual

Reimplemented in GlobalProgressIndicator.

Referenced by setRange().

virtual void ProgressIndicator::onStart ( )
protectedpure virtual

Implemented in ConsoleProgressIndicator, and GlobalProgressIndicator.

Referenced by start().

float ProgressIndicator::percentage ( ) const
inline
bool ProgressIndicator::poll ( int  progress)
inline
int ProgressIndicator::progress ( ) const
inline
virtual void ProgressIndicator::setLabel ( const std::string &  label)
inlinevirtual
void ProgressIndicator::setRange ( int  min,
int  max 
)
inline
virtual void ProgressIndicator::setTitle ( const std::string &  title)
inlinevirtual

References m_title, and title().

Referenced by GlobalProgressIndicator::setTitle().

void ProgressIndicator::start ( )
inline
void ProgressIndicator::step ( )
inline

References m_progress, and poll().

std::string ProgressIndicator::title ( ) const
inline
std::string& ProgressIndicator::title ( )
inline

References m_title.

bool ProgressIndicator::wasCanceled ( ) const
inline

Member Data Documentation

bool ProgressIndicator::m_canceled
protected

Referenced by poll(), start(), and wasCanceled().

std::string ProgressIndicator::m_label
protected

Referenced by label(), and setLabel().

int ProgressIndicator::m_maxValue
protected

Referenced by finish(), maxValue(), percentage(), and setRange().

int ProgressIndicator::m_minValue
protected

Referenced by minValue(), percentage(), setRange(), and start().

int ProgressIndicator::m_progress
protected
std::string ProgressIndicator::m_title
protected

Referenced by setTitle(), and title().