library of assembled shared sources

http://lass.cocamware.com

lass::util::ProgressIndicator Class Reference

Prints a progress indication to console. More...

#include <progress_indicator.h>

Collaboration diagram for lass::util::ProgressIndicator:

Collaboration graph
[legend]

Public Member Functions

 ProgressIndicator (const std::string &iDescription, int iConsoleWidth=80)
 ~ProgressIndicator ()
 print final message on destruction
void operator() (double iProgress)
 update progress indicator

Private Attributes

Clock clock_
Clock::TTime timeLeftBuffer_
Clock::TTime previousTimeElapsed_
std::string description_
std::string backslash_
std::string whitespace_
int consoleWidth_
int current_
int timeLeftIndex_

Detailed Description

Prints a progress indication to console.

    {
        ProgressIndicator indicator("doing something")
        const int n = 1000;
        for (int i = 0; i < n; ++i)
        {
            doSomething();
            indicator(double(i) / n);
        }
    } // when indicator goes out of scope, it prints a final message.

Definition at line 70 of file progress_indicator.h.


Constructor & Destructor Documentation

lass::util::ProgressIndicator::ProgressIndicator ( const std::string &  iDescription,
int  iConsoleWidth = 80 
)

Parameters:
iDescriptor description printed at begin of the line
iConsoleWidth maximum number of characters on one console text line (default=80)

Definition at line 55 of file progress_indicator.cpp.

References consoleWidth_, lass::io::cout(), description_, and whitespace_.

lass::util::ProgressIndicator::~ProgressIndicator (  ) 

print final message on destruction

Definition at line 72 of file progress_indicator.cpp.


Member Function Documentation

void lass::util::ProgressIndicator::operator() ( double  iProgress  ) 

update progress indicator

Parameters:
iProgress value in range [0, 1]

Definition at line 80 of file progress_indicator.cpp.

References lass::num::clamp(), clock_, consoleWidth_, lass::io::cout(), current_, description_, lass::util::Clock::humanize(), previousTimeElapsed_, lass::util::Clock::time(), timeLeftBuffer_, and whitespace_.


Field Documentation

Definition at line 78 of file progress_indicator.h.

Referenced by operator()().

Definition at line 79 of file progress_indicator.h.

Referenced by operator()().

Definition at line 80 of file progress_indicator.h.

Referenced by operator()().

Definition at line 81 of file progress_indicator.h.

Referenced by operator()(), and ProgressIndicator().

Definition at line 82 of file progress_indicator.h.

Definition at line 83 of file progress_indicator.h.

Referenced by operator()(), and ProgressIndicator().

Definition at line 84 of file progress_indicator.h.

Referenced by operator()(), and ProgressIndicator().

Definition at line 85 of file progress_indicator.h.

Referenced by operator()().

Definition at line 86 of file progress_indicator.h.


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

Generated on Mon Nov 10 14:22:17 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo