/** @file Dk4WxProgressControllerBase.h Progress controller base class. */ #ifndef DK4WXPROGRESSCONTROLLERBASE_H_INCLUDED #define DK4WXPROGRESSCONTROLLERBASE_H_INCLUDED 1 /** Base class for progress controllers interface to worker thread. */ class Dk4WxProgressControllerWorkerBase { public: /* While the worker thread is running, it can - check whether the worker thread is allowed to continue, - set a new gauge value for the progress bar in the progress dialog, - indicate that the main thread should show a dialog box after the worker thread has finished, - indicate end of processing immediately before finishing. */ /** Check whether worker thread is allowed to continue processing. @return True if worker thread can continue normally, false if worker thread should abort. */ virtual bool CanContinue(void) = 0; /** Set gauge value for progress dialog. @param value New value for gauge. */ virtual void SetGauge(int value) = 0; /** Indicate that a dialog box should be shown by the main thread after the worker thread has finished. @param title Message box title. @param msg Message box text. @param st Message box style. */ virtual void SetDialogData( const wxString & title, const wxString & msg, int st = wxID_OK ) = 0; /** End processing. Called from worker thread immediately before finished. Note: If you want to call SetGaugeValue() or SetDialogData(), call these functions before EndProcessing(). @param success Flag: Successful processing. */ virtual void EndProcessing(bool success = true) = 0; }; /** Progress controllers interface to event processing (main) thread. */ class Dk4WxProgressControllerOwnerBase { public: /* Before the worker thread is started either the main thread or the worker thread should indicate start of processing. */ /** Start processing. Optionally called from worker thread or main thread. Must be called if a controller is used multiple times. */ virtual void StartProcessing(void) = 0; /* While the worker thread is running, the main thread (event thread) can - check whether the worker thread finished processing, - retrieve the current gauge value, - abort processing on behalf of the progress dialogs cancel button. */ /** Check whether the worker thread is finished. @return True if the worker thread is finished, false while running. */ virtual bool IsFinished(void) = 0; /** Retrieve gauge value. @return Current value for progress gauge. */ virtual int GetGauge(void) = 0; /** Abort processing. Called from the progress dialogs Cancel button. */ virtual void AbortProcessing(void) = 0; /* After the worker thread finished processing, the event thread can: - check whether the worker thread finished successfully, - check whether a dialog box should show a processing summary. */ /** Check whether the worker thread finished successfully. @return True to indicate success, false otherwise. */ virtual bool GetSuccess(void) = 0; /** Check whether a dialog should be shown. @param title Result variable for message box title. @param msg Result variable for message text. @param style Result variable for dialog box style. @return True to show a dialog, false otherwise. */ virtual bool GetDialogData(wxString & title, wxString & msg, int & style) = 0; }; #endif