|
PLearn 0.1
|
Simple plugin for displaying text progress bar. More...
#include <ProgressBar.h>


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 |
Simple plugin for displaying text progress bar.
Definition at line 79 of file ProgressBar.h.
| 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) { }
| 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();
}
}

| 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;
}
}
}

PStream PLearn::TextProgressBarPlugin::out [protected] |
Definition at line 82 of file ProgressBar.h.
Referenced by PLearn::LineOutputProgressBarPlugin::addProgressBar(), addProgressBar(), PLearn::LineOutputProgressBarPlugin::killProgressBar(), PLearn::RemoteProgressBarPlugin::killProgressBar(), PLearn::RemoteProgressBarPlugin::printTitle(), TextProgressBarPlugin(), PLearn::LineOutputProgressBarPlugin::update(), PLearn::RemoteProgressBarPlugin::update(), and update().
int PLearn::TextProgressBarPlugin::width = 100 [static] |
Displayed width of the text progress bar. Default=100.
Definition at line 91 of file ProgressBar.h.
Referenced by addProgressBar(), and update().
1.7.4