KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PROGRESS_REPORTER_BASE Class Referenceabstract

This implements all the tricky bits for thread safety, but the GUI is left to derived classes. More...

#include <progress_reporter_base.h>

Inheritance diagram for PROGRESS_REPORTER_BASE:
PROGRESS_REPORTER BACKGROUND_JOB_REPORTER CONSOLE_PROGRESS_REPORTER DIALOG_DRC DIALOG_ERC DIALOG_PCM_PROGRESS GAUGE_PROGRESS_REPORTER WX_PROGRESS_REPORTER

Public Member Functions

 PROGRESS_REPORTER_BASE (int aNumPhases)
 
 PROGRESS_REPORTER_BASE (const PROGRESS_REPORTER_BASE &)=delete
 
virtual ~PROGRESS_REPORTER_BASE ()
 
void SetNumPhases (int aNumPhases) override
 Set the number of phases.
 
void AddPhases (int aNumPhases) override
 
virtual void BeginPhase (int aPhase) override
 Initialize the aPhase virtual zone of the dialog progress bar.
 
virtual void AdvancePhase () override
 Use the next available virtual zone of the dialog progress bar.
 
virtual void AdvancePhase (const wxString &aMessage) override
 Use the next available virtual zone of the dialog progress bar and updates the message.
 
virtual void Report (const wxString &aMessage) override
 Display aMessage in the progress bar dialog.
 
virtual void SetCurrentProgress (double aProgress) override
 Set the progress value to aProgress (0..1).
 
void SetMaxProgress (int aMaxProgress) override
 Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
 
void AdvanceProgress () override
 Increment the progress bar length (inside the current virtual zone).
 
bool KeepRefreshing (bool aWait=false) override
 Update the UI dialog.
 
void SetTitle (const wxString &aTitle) override
 Change the title displayed on the window caption.
 
bool IsCancelled () const override
 
int CurrentProgress () const
 

Protected Member Functions

virtual bool updateUI ()=0
 

Protected Attributes

wxString m_rptMessage
 
std::mutex m_mutex
 
std::atomic_int m_phase
 
std::atomic_int m_numPhases
 
std::atomic_int m_progress
 
std::atomic_int m_maxProgress
 
std::atomic_bool m_cancelled
 
std::atomic_bool m_messageChanged
 

Detailed Description

This implements all the tricky bits for thread safety, but the GUI is left to derived classes.

Definition at line 37 of file progress_reporter_base.h.

Constructor & Destructor Documentation

◆ PROGRESS_REPORTER_BASE() [1/2]

PROGRESS_REPORTER_BASE::PROGRESS_REPORTER_BASE ( int  aNumPhases)

Definition at line 31 of file progress_reporter_base.cpp.

◆ PROGRESS_REPORTER_BASE() [2/2]

PROGRESS_REPORTER_BASE::PROGRESS_REPORTER_BASE ( const PROGRESS_REPORTER_BASE )
delete

◆ ~PROGRESS_REPORTER_BASE()

virtual PROGRESS_REPORTER_BASE::~PROGRESS_REPORTER_BASE ( )
inlinevirtual

Definition at line 44 of file progress_reporter_base.h.

Member Function Documentation

◆ AddPhases()

void PROGRESS_REPORTER_BASE::AddPhases ( int  aNumPhases)
overridevirtual

Implements PROGRESS_REPORTER.

Definition at line 98 of file progress_reporter_base.cpp.

References m_numPhases.

◆ AdvancePhase() [1/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( )
overridevirtual

Use the next available virtual zone of the dialog progress bar.

Implements PROGRESS_REPORTER.

Reimplemented in BACKGROUND_JOB_REPORTER, and DIALOG_PCM_PROGRESS.

Definition at line 50 of file progress_reporter_base.cpp.

References m_phase, and m_progress.

Referenced by BACKGROUND_JOB_REPORTER::AdvancePhase(), DIALOG_PCM_PROGRESS::AdvancePhase(), DIALOG_ERC::AdvancePhase(), AdvancePhase(), and DIALOG_DRC::AdvancePhase().

◆ AdvancePhase() [2/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( const wxString &  aMessage)
overridevirtual

Use the next available virtual zone of the dialog progress bar and updates the message.

Implements PROGRESS_REPORTER.

Reimplemented in DIALOG_ERC, and DIALOG_DRC.

Definition at line 57 of file progress_reporter_base.cpp.

References AdvancePhase(), and Report().

◆ AdvanceProgress()

void PROGRESS_REPORTER_BASE::AdvanceProgress ( )
overridevirtual

Increment the progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 86 of file progress_reporter_base.cpp.

References m_progress.

◆ BeginPhase()

void PROGRESS_REPORTER_BASE::BeginPhase ( int  aPhase)
overridevirtual

Initialize the aPhase virtual zone of the dialog progress bar.

Implements PROGRESS_REPORTER.

Definition at line 43 of file progress_reporter_base.cpp.

References m_phase, and m_progress.

◆ CurrentProgress()

int PROGRESS_REPORTER_BASE::CurrentProgress ( ) const

◆ IsCancelled()

bool PROGRESS_REPORTER_BASE::IsCancelled ( ) const
inlineoverridevirtual

Implements PROGRESS_REPORTER.

Definition at line 108 of file progress_reporter_base.h.

Referenced by SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME().

◆ KeepRefreshing()

bool PROGRESS_REPORTER_BASE::KeepRefreshing ( bool  aWait = false)
overridevirtual

Update the UI dialog.

Warning
This should only be called from the main thread.
Returns
false if the user clicked Cancel.

Implements PROGRESS_REPORTER.

Definition at line 113 of file progress_reporter_base.cpp.

References m_cancelled, m_maxProgress, m_progress, and updateUI().

Referenced by PCB_EDIT_FRAME::GenIPC2581File().

◆ Report()

void PROGRESS_REPORTER_BASE::Report ( const wxString &  aMessage)
overridevirtual

Display aMessage in the progress bar dialog.

Implements PROGRESS_REPORTER.

Reimplemented in DIALOG_ERC, and BACKGROUND_JOB_REPORTER.

Definition at line 64 of file progress_reporter_base.cpp.

References m_messageChanged, m_mutex, and m_rptMessage.

Referenced by AdvancePhase().

◆ SetCurrentProgress()

void PROGRESS_REPORTER_BASE::SetCurrentProgress ( double  aProgress)
overridevirtual

Set the progress value to aProgress (0..1).

Implements PROGRESS_REPORTER.

Reimplemented in CONSOLE_PROGRESS_REPORTER, and CONSOLE_PROGRESS_REPORTER.

Definition at line 79 of file progress_reporter_base.cpp.

References m_maxProgress, and m_progress.

Referenced by DIALOG_ERC::AdvancePhase(), DIALOG_DRC::AdvancePhase(), and CONSOLE_PROGRESS_REPORTER::SetCurrentProgress().

◆ SetMaxProgress()

void PROGRESS_REPORTER_BASE::SetMaxProgress ( int  aMaxProgress)
overridevirtual

Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 73 of file progress_reporter_base.cpp.

References m_maxProgress.

◆ SetNumPhases()

void PROGRESS_REPORTER_BASE::SetNumPhases ( int  aNumPhases)
overridevirtual

Set the number of phases.

Implements PROGRESS_REPORTER.

Definition at line 92 of file progress_reporter_base.cpp.

References m_numPhases.

Referenced by DIALOG_PCM_PROGRESS::OnCancelClicked(), and BACKGROUND_JOB_REPORTER::SetNumPhases().

◆ SetTitle()

void PROGRESS_REPORTER_BASE::SetTitle ( const wxString &  aTitle)
inlineoverridevirtual

Change the title displayed on the window caption.

Has meaning only for some reporters. Does nothing for others.

Warning
This should only be called from the main thread.

Implements PROGRESS_REPORTER.

Reimplemented in WX_PROGRESS_REPORTER.

Definition at line 106 of file progress_reporter_base.h.

◆ updateUI()

virtual bool PROGRESS_REPORTER_BASE::updateUI ( )
protectedpure virtual

Member Data Documentation

◆ m_cancelled

◆ m_maxProgress

◆ m_messageChanged

std::atomic_bool PROGRESS_REPORTER_BASE::m_messageChanged
protected

Definition at line 129 of file progress_reporter_base.h.

Referenced by Report(), and WX_PROGRESS_REPORTER::updateUI().

◆ m_mutex

std::mutex PROGRESS_REPORTER_BASE::m_mutex
mutableprotected

◆ m_numPhases

std::atomic_int PROGRESS_REPORTER_BASE::m_numPhases
protected

◆ m_phase

std::atomic_int PROGRESS_REPORTER_BASE::m_phase
protected

◆ m_progress

◆ m_rptMessage

wxString PROGRESS_REPORTER_BASE::m_rptMessage
protected

The documentation for this class was generated from the following files: