PLearn 0.1
Public Member Functions | Protected Attributes
PLearn::PlideProgressPlugin Class Reference
Inheritance diagram for PLearn::PlideProgressPlugin:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PlideProgressPlugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PlideProgressPlugin (PythonCodeSnippet *python)
virtual ~PlideProgressPlugin ()
 Destructor releases all pending progress bars from GUI.
virtual void addProgressBar (ProgressBar *pb)
 Try to allocate a GUI element for progress bar.
virtual void killProgressBar (ProgressBar *pb)
 Release the allocated GUI element for progress bar.
virtual void update (ProgressBar *pb, unsigned long newpos)
 Update GUI element if there's one associated with progress bar.

Protected Attributes

PythonCodeSnippetm_python
 Python environment for execution.
map< ProgressBar *, intm_progress_ids
 Map from the progress bar to a GUI id for transmitting the update.

Detailed Description

Definition at line 68 of file Plide.cc.


Constructor & Destructor Documentation

PLearn::PlideProgressPlugin::PlideProgressPlugin ( PythonCodeSnippet python) [inline]

Definition at line 71 of file Plide.cc.

References PLASSERT.

        : m_python(python)
    {
        PLASSERT( m_python );
    }
PLearn::PlideProgressPlugin::~PlideProgressPlugin ( ) [virtual]

Destructor releases all pending progress bars from GUI.

Definition at line 98 of file Plide.cc.

References PLASSERT.

{
    PLASSERT( m_python );
    for (map<ProgressBar*, int>::const_iterator it = m_progress_ids.begin(),
             end = m_progress_ids.end() ; it != end ; ++it)
    {
        // Don't call killProgressBar since iterators might be invalidated
        m_python->invoke("ReleaseProgressBar", int(it->second));
    }
    m_progress_ids.clear();
}

Member Function Documentation

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

Try to allocate a GUI element for progress bar.

Reimplemented from PLearn::ProgressBarPlugin.

Definition at line 110 of file Plide.cc.

References PLASSERT, and PLearn::ProgressBar::title.

{
    PLASSERT( pb && m_python );
    if (m_progress_ids.find(pb) == m_progress_ids.end()) {
        m_progress_ids[pb] =
            m_python->invoke("AllocateProgressBar", pb->title).as<int>();
    }
}
void PLearn::PlideProgressPlugin::killProgressBar ( ProgressBar pb) [virtual]

Release the allocated GUI element for progress bar.

Reimplemented from PLearn::ProgressBarPlugin.

Definition at line 119 of file Plide.cc.

References PLASSERT.

{
    PLASSERT( pb && m_python );
    map<ProgressBar*, int>::iterator found = m_progress_ids.find(pb);
    if (found != m_progress_ids.end()) {
        m_python->invoke("ReleaseProgressBar", int(found->second));
        m_progress_ids.erase(found);
    }
}
void PLearn::PlideProgressPlugin::update ( ProgressBar pb,
unsigned long  newpos 
) [virtual]

Update GUI element if there's one associated with progress bar.

Definition at line 129 of file Plide.cc.

References PLearn::ProgressBar::maxpos, and PLASSERT.

{
    PLASSERT( pb && m_python );
    map<ProgressBar*, int>::const_iterator found = m_progress_ids.find(pb);
    if (found != m_progress_ids.end()) {
        int progress_id = found->second;
        double fraction = double(newpos) / double(pb->maxpos);
        m_python->invoke("ProgressUpdate", progress_id, fraction);
    }
}

Member Data Documentation

Map from the progress bar to a GUI id for transmitting the update.

The id is -1 if there is no associated GUI element.

Definition at line 95 of file Plide.cc.

Python environment for execution.

Definition at line 91 of file Plide.cc.


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