aimsdata  4.7.0
Neuroimaging data handling
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...
 
double rescale (const T1 &value) const
 Rescale value to its progression value. More...
 
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...
 
virtual void print (const bool force=false)
 Print to cout if value changed or forced. 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

◆ ProgressInfo() [1/2]

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

◆ ProgressInfo() [2/2]

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

◆ current()

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

Current value.

◆ erase()

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

Erase the last displayed value.

◆ operator++() [1/2]

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

Prefix operator to increment internal value.

◆ operator++() [2/2]

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

Postfix operator to increment internal value.

◆ operator+=()

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.

◆ print()

template<class T1 = double, class T2 = double>
virtual void aims::ProgressInfo< T1, T2 >::print ( const bool  force = false)
virtual

Print to cout if value changed or forced.

◆ progression()

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

Current progression value.

◆ render()

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 aims::operator<<().

◆ rescale()

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

Rescale value to its progression value.

◆ reset()

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

Reset the progession to minimum value.

◆ scale()

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.

◆ toString()

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

◆ _current

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

Definition at line 123 of file progress.h.

◆ _displayed

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

Definition at line 121 of file progress.h.

◆ _max

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

Definition at line 123 of file progress.h.

◆ _min

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

Definition at line 123 of file progress.h.

◆ _progressmax

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

Definition at line 124 of file progress.h.

◆ _progressmin

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

Definition at line 124 of file progress.h.

◆ _progressprec

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

Definition at line 124 of file progress.h.

◆ _scale

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

Definition at line 122 of file progress.h.

◆ _unit

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

Definition at line 125 of file progress.h.

◆ _width

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

Definition at line 121 of file progress.h.


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