PLearn 0.1
Public Member Functions | Static Protected Member Functions | Protected Attributes
PLearn::LineOutputProgressBarPlugin Class Reference

Similar to TextProgressBarPlugin with a different output format so that updates appear on different lines of output. More...

#include <ProgressBar.h>

Inheritance diagram for PLearn::LineOutputProgressBarPlugin:
Inheritance graph
[legend]
Collaboration diagram for PLearn::LineOutputProgressBarPlugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void addProgressBar (ProgressBar *pb)
virtual void update (ProgressBar *pb, uint32_t newpos)
 LineOutputProgressBarPlugin (ostream &_out, unsigned int nticks_=100)
 LineOutputProgressBarPlugin (PStream &_out, unsigned int nticks_=100)
virtual void killProgressBar (ProgressBar *pb)

Static Protected Member Functions

static string pbInfo (ProgressBar *pb)

Protected Attributes

unsigned int nticks

Detailed Description

Similar to TextProgressBarPlugin with a different output format so that updates appear on different lines of output.

(for logging or when multiple progress bars are used simultaneously)

Definition at line 118 of file ProgressBar.h.


Constructor & Destructor Documentation

PLearn::LineOutputProgressBarPlugin::LineOutputProgressBarPlugin ( ostream &  _out,
unsigned int  nticks_ = 100 
)

Definition at line 238 of file ProgressBar.cc.

    :TextProgressBarPlugin(_out), nticks(nticks_)
{}
PLearn::LineOutputProgressBarPlugin::LineOutputProgressBarPlugin ( PStream _out,
unsigned int  nticks_ = 100 
)

Definition at line 242 of file ProgressBar.cc.

    :TextProgressBarPlugin(_out), nticks(nticks_)
{}

Member Function Documentation

void PLearn::LineOutputProgressBarPlugin::addProgressBar ( ProgressBar pb) [virtual]

Reimplemented from PLearn::TextProgressBarPlugin.

Definition at line 246 of file ProgressBar.cc.

References PLearn::endl(), PLearn::TextProgressBarPlugin::out, and pbInfo().

{ out << "In progress: " << pbInfo(pb) << endl; }

Here is the call graph for this function:

void PLearn::LineOutputProgressBarPlugin::killProgressBar ( ProgressBar pb) [virtual]

Reimplemented from PLearn::ProgressBarPlugin.

Definition at line 263 of file ProgressBar.cc.

References PLearn::endl(), PLearn::TextProgressBarPlugin::out, and pbInfo().

{ out << pbInfo(pb) << " Finished" << endl; }

Here is the call graph for this function:

string PLearn::LineOutputProgressBarPlugin::pbInfo ( ProgressBar pb) [static, protected]

Definition at line 266 of file ProgressBar.cc.

References PLearn::ProgressBar::currentpos, PLearn::ProgressBar::maxpos, PLearn::ProgressBar::title, and PLearn::tostring().

Referenced by addProgressBar(), killProgressBar(), and update().

{
    unsigned int curpos= pb->currentpos,
                 maxpos= pb->maxpos;
    return string("[") + pb->title + "] " 
        + tostring(curpos) + '/' + tostring(maxpos)
        + " (" + tostring(static_cast<double>(curpos)*100.0 / static_cast<double>(maxpos)) + "%)";
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::LineOutputProgressBarPlugin::update ( ProgressBar pb,
uint32_t  newpos 
) [virtual]

Reimplemented from PLearn::TextProgressBarPlugin.

Definition at line 249 of file ProgressBar.cc.

References PLearn::ProgressBar::currentpos, PLearn::endl(), PLearn::ProgressBar::maxpos, nticks, PLearn::TextProgressBarPlugin::out, and pbInfo().

{
    // this handles the case where we reuse the same progress bar
    if(newpos < pb->currentpos)
    {
        pb->currentpos= newpos;
        out << "In progress: ";//to be continued...
    }
    else if(0 <  (int( newpos / (double(pb->maxpos) / nticks) ) -
             int(round( pb->currentpos / (double(pb->maxpos) / nticks) ))))
        pb->currentpos= newpos;
    out << pbInfo(pb) << endl;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 131 of file ProgressBar.h.

Referenced by update().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines