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

Simple plugin for displaying text progress bar. More...

#include <ProgressBar.h>

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

List of all members.

Public Member Functions

virtual void addProgressBar (ProgressBar *pb)
virtual void update (ProgressBar *pb, uint32_t newpos)
 TextProgressBarPlugin (ostream &_out)
 TextProgressBarPlugin (PStream &_out)

Static Public Attributes

static int width = 100
 Displayed width of the text progress bar. Default=100.

Protected Attributes

PStream out

Detailed Description

Simple plugin for displaying text progress bar.

Definition at line 79 of file ProgressBar.h.


Constructor & Destructor Documentation

PLearn::TextProgressBarPlugin::TextProgressBarPlugin ( ostream &  _out)

Definition at line 118 of file ProgressBar.cc.

References out, PLearn::PStream::outmode, and PLearn::PStream::raw_ascii.

    :out(&_out)
{
    out.outmode=PStream::raw_ascii;
}
PLearn::TextProgressBarPlugin::TextProgressBarPlugin ( PStream _out)

Definition at line 124 of file ProgressBar.cc.

    :out(_out)
{
}

Member Function Documentation

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

Reimplemented from PLearn::ProgressBarPlugin.

Reimplemented in PLearn::RemoteProgressBarPlugin, and PLearn::LineOutputProgressBarPlugin.

Definition at line 129 of file ProgressBar.cc.

References PLearn::center(), PLearn::PStream::flush(), PLearn::ProgressBar::maxpos, out, PLearn::PLMPI::rank, PLearn::ProgressBar::title, PLearn::tostring(), and width.

{
#if USING_MPI
    if(PLMPI::rank==0)
#elif _OPENMP
    if(omp_get_thread_num()==0)
#endif
    {

        string fulltitle = string(" ") + pb->title + " (" + tostring(pb->maxpos) + ") ";
        out << "[" + center(fulltitle,width,'-') + "]\n[";
        out.flush();
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::ProgressBarPlugin.

Reimplemented in PLearn::RemoteProgressBarPlugin, and PLearn::LineOutputProgressBarPlugin.

Definition at line 144 of file ProgressBar.cc.

References PLearn::center(), PLearn::ProgressBar::currentpos, PLearn::endl(), PLearn::PStream::flush(), PLearn::ProgressBar::maxpos, out, PLERROR, PLearn::PLMPI::rank, PLearn::ProgressBar::title, PLearn::tostring(), and width.

{
#if USING_MPI
    if(PLMPI::rank==0)
#elif _OPENMP
    if(omp_get_thread_num()==0)
#endif
    {
        // this handles the case where we reuse the same progress bar
        if(newpos < pb->currentpos)
        {
            pb->currentpos=0;
            string fulltitle = string(" ") + pb->title + " (" + tostring(pb->maxpos) + ") ";
            out << "\n[" + center(fulltitle,width,'-') + "]\n[";
            out.flush();
        }

        if(!pb->maxpos || newpos>pb->maxpos)
            return;
        int ndots = int(round( newpos / (double(pb->maxpos) / width) )) -
            int(round( pb->currentpos / (double(pb->maxpos) / width) ));
        if (ndots < 0)
            PLERROR("In TextProgressBarPlugin::update - Trying to plot an infinite number of dots");
        while(ndots--)
            out << '.';
        out.flush();
        pb->currentpos = newpos;
        if(pb->currentpos==pb->maxpos)
        {
            out << "]";
            out << endl;
        }
    }
}

Here is the call graph for this function:


Member Data Documentation

Displayed width of the text progress bar. Default=100.

Definition at line 91 of file ProgressBar.h.

Referenced by addProgressBar(), and update().


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