A.I.M.S


aims::ProgressInfo< T1, T2 > Class Template Reference

The template class used to display progression in text mode. More...

#include <aims/utility/progress.h>

Collaboration diagram for aims::ProgressInfo< T1, T2 >:

Public Member Functions

Constructor and Destructor
 ProgressInfo (const T1 min, const T1 max, const T2 progressmin=(T2) 0, const T2 progressmax=(T2) 100, const std::string unit="%", const int width=3)
 Constructor of the class. More...
 
 ProgressInfo (const T1 max)
 Constructor of the class. More...
 
Methods
T1 & current ()
 Current value. More...
 
void reset ()
 Reset the progession to minimum value. More...
 
const double & scale () const
 Scale that is used between displayed progession range and values. More...
 
const double rescale (const T1 &value) const
 Rescale value to its progression value. More...
 
const double progression () const
 Current progression value. More...
 
virtual std::string erase () const
 Erase the last displayed value. More...
 
virtual std::string render (const bool force=false)
 Render the current progression value if changed or forced. More...
 
virtual std::string toString () const
 Convert progression to the display string. More...
 
ProgressInfo< T1, T2 > & operator++ ()
 Prefix operator to increment internal value. More...
 
ProgressInfo< T1, T2 > operator++ (int)
 Postfix operator to increment internal value. More...
 
ProgressInfo< T1, T2 > & operator+= (const T1 &r)
 Compound assignement operator to increment internal value. More...
 

Protected Attributes

int _displayed
 
int _width
 
double _scale
 
T1 _current
 
T1 _min
 
T1 _max
 
T2 _progressprec
 
T2 _progressmin
 
T2 _progressmax
 
std::string _unit
 

Detailed Description

template<class T1 = double, class T2 = double>
class aims::ProgressInfo< T1, T2 >

The template class used to display progression in text mode.

/ Here is an example of how to use the Progression class: / /

#include <iostream>
#include <unistd.h>
int main( int argc, const char* argv[] ) {
int start = 10, end = 1000;
aims::Progression progress(start, end);
std::cout << "Progress ";
for (int i = start; i <= end; ++i, ++progress)
{
usleep(1000);
std::cout << progress << std::flush;
}
std::cout << std::endl;
}
///

Definition at line 65 of file progress.h.

Constructor & Destructor Documentation

template<class T1 = double, class T2 = double>
aims::ProgressInfo< T1, T2 >::ProgressInfo ( const T1  min,
const T1  max,
const T2  progressmin = (T2) 0,
const T2  progressmax = (T2) 100,
const std::string  unit = "%",
const int  width = 3 
)

Constructor of the class.

Parameters
minminimum value of the progression
maxmaximum value of the progression
progressminminimum displayed value [default=0]
progressmaxmaximum displayed value [default=100]
unitunit of the displayed value
widthnumber of charecters used to display the value
template<class T1 = double, class T2 = double>
aims::ProgressInfo< T1, T2 >::ProgressInfo ( const T1  max)

Constructor of the class.

Parameters
maxmaximum value of the progression

Member Function Documentation

template<class T1 = double, class T2 = double>
T1& aims::ProgressInfo< T1, T2 >::current ( )

Current value.

template<class T1 = double, class T2 = double>
virtual std::string aims::ProgressInfo< T1, T2 >::erase ( ) const
virtual

Erase the last displayed value.

template<class T1 = double, class T2 = double>
ProgressInfo<T1, T2>& aims::ProgressInfo< T1, T2 >::operator++ ( )

Prefix operator to increment internal value.

template<class T1 = double, class T2 = double>
ProgressInfo<T1, T2> aims::ProgressInfo< T1, T2 >::operator++ ( int  )

Postfix operator to increment internal value.

template<class T1 = double, class T2 = double>
ProgressInfo<T1, T2>& aims::ProgressInfo< T1, T2 >::operator+= ( const T1 &  r)

Compound assignement operator to increment internal value.

template<class T1 = double, class T2 = double>
const double aims::ProgressInfo< T1, T2 >::progression ( ) const

Current progression value.

template<class T1 = double, class T2 = double>
virtual std::string aims::ProgressInfo< T1, T2 >::render ( const bool  force = false)
virtual

Render the current progression value if changed or forced.

Parameters
forceforce to render even the displayed value has not changed

Referenced by operator<<().

template<class T1 = double, class T2 = double>
const double aims::ProgressInfo< T1, T2 >::rescale ( const T1 &  value) const

Rescale value to its progression value.

template<class T1 = double, class T2 = double>
void aims::ProgressInfo< T1, T2 >::reset ( )

Reset the progession to minimum value.

template<class T1 = double, class T2 = double>
const double& aims::ProgressInfo< T1, T2 >::scale ( ) const

Scale that is used between displayed progession range and values.

template<class T1 = double, class T2 = double>
virtual std::string aims::ProgressInfo< T1, T2 >::toString ( ) const
virtual

Convert progression to the display string.

Member Data Documentation

template<class T1 = double, class T2 = double>
T1 aims::ProgressInfo< T1, T2 >::_current
protected

Definition at line 121 of file progress.h.

template<class T1 = double, class T2 = double>
int aims::ProgressInfo< T1, T2 >::_displayed
protected

Definition at line 119 of file progress.h.

template<class T1 = double, class T2 = double>
T1 aims::ProgressInfo< T1, T2 >::_max
protected

Definition at line 121 of file progress.h.

template<class T1 = double, class T2 = double>
T1 aims::ProgressInfo< T1, T2 >::_min
protected

Definition at line 121 of file progress.h.

template<class T1 = double, class T2 = double>
T2 aims::ProgressInfo< T1, T2 >::_progressmax
protected

Definition at line 122 of file progress.h.

template<class T1 = double, class T2 = double>
T2 aims::ProgressInfo< T1, T2 >::_progressmin
protected

Definition at line 122 of file progress.h.

template<class T1 = double, class T2 = double>
T2 aims::ProgressInfo< T1, T2 >::_progressprec
protected

Definition at line 122 of file progress.h.

template<class T1 = double, class T2 = double>
double aims::ProgressInfo< T1, T2 >::_scale
protected

Definition at line 120 of file progress.h.

template<class T1 = double, class T2 = double>
std::string aims::ProgressInfo< T1, T2 >::_unit
protected

Definition at line 123 of file progress.h.

template<class T1 = double, class T2 = double>
int aims::ProgressInfo< T1, T2 >::_width
protected

Definition at line 119 of file progress.h.


The documentation for this class was generated from the following file: