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

Similar to TextProgressBarPlugin with a different output format so that remote servers can update progress bars on a client. More...

#include <ProgressBar.h>

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

List of all members.

Public Member Functions

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

Protected Member Functions

void printTitle (ProgressBar *pb)

Static Protected Member Functions

static unsigned int getPBarID (ProgressBar *pb)

Protected Attributes

unsigned int nticks

Static Protected Attributes

static map< ProgressBar
*, unsigned int
pb_ids
static unsigned int next_pb_id = 0

Detailed Description

Similar to TextProgressBarPlugin with a different output format so that remote servers can update progress bars on a client.

Definition at line 96 of file ProgressBar.h.


Constructor & Destructor Documentation

PLearn::RemoteProgressBarPlugin::RemoteProgressBarPlugin ( ostream &  _out,
unsigned int  nticks_ = 20 
)

Definition at line 183 of file ProgressBar.cc.

    :TextProgressBarPlugin(_out), nticks(nticks_)
{}
PLearn::RemoteProgressBarPlugin::RemoteProgressBarPlugin ( PStream _out,
unsigned int  nticks_ = 20 
)

Definition at line 187 of file ProgressBar.cc.

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

Member Function Documentation

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

Reimplemented from PLearn::TextProgressBarPlugin.

Definition at line 191 of file ProgressBar.cc.

References printTitle().

{ printTitle(pb); }

Here is the call graph for this function:

unsigned int PLearn::RemoteProgressBarPlugin::getPBarID ( ProgressBar pb) [static, protected]

Definition at line 197 of file ProgressBar.cc.

References next_pb_id, and pb_ids.

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

{
    if(pb_ids.find(pb) == pb_ids.end())
        pb_ids[pb]= ++next_pb_id;
    return pb_ids[pb];
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::ProgressBarPlugin.

Definition at line 229 of file ProgressBar.cc.

References PLearn::endl(), getPBarID(), PLearn::TextProgressBarPlugin::out, and PLearn::PStream::write().

{
    out.write("*PK ");
    out << getPBarID(pb) << endl;
}

Here is the call graph for this function:

void PLearn::RemoteProgressBarPlugin::printTitle ( ProgressBar pb) [protected]

Definition at line 222 of file ProgressBar.cc.

References PLearn::endl(), getPBarID(), PLearn::ProgressBar::maxpos, PLearn::TextProgressBarPlugin::out, PLearn::ProgressBar::title, PLearn::tostring(), and PLearn::PStream::write().

Referenced by addProgressBar(), and update().

{
    string fulltitle = string(" ") + pb->title + " (" + tostring(pb->maxpos) + ") ";
    out.write("*PA ");
    out << getPBarID(pb) << pb->maxpos << fulltitle << endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::TextProgressBarPlugin.

Definition at line 205 of file ProgressBar.cc.

References PLearn::ProgressBar::currentpos, PLearn::endl(), getPBarID(), PLearn::ProgressBar::maxpos, nticks, PLearn::TextProgressBarPlugin::out, printTitle(), and PLearn::PStream::write().

{
    // this handles the case where we reuse the same progress bar
    if(newpos < pb->currentpos)
    {
        pb->currentpos=0;
        printTitle(pb);
    }
    if(0 <  (int( newpos / (double(pb->maxpos) / nticks) ) -
             int(round( pb->currentpos / (double(pb->maxpos) / nticks) ))))
    {
        out.write("*PU ");
        out << getPBarID(pb) << newpos << endl;
        pb->currentpos = newpos;
    }
}

Here is the call graph for this function:


Member Data Documentation

unsigned int PLearn::RemoteProgressBarPlugin::next_pb_id = 0 [static, protected]

Definition at line 109 of file ProgressBar.h.

Referenced by getPBarID().

Definition at line 112 of file ProgressBar.h.

Referenced by update().

map< ProgressBar *, unsigned int > PLearn::RemoteProgressBarPlugin::pb_ids [static, protected]

Definition at line 108 of file ProgressBar.h.

Referenced by getPBarID().


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