diff options
Diffstat (limited to 'library/status_handler.h')
-rw-r--r-- | library/status_handler.h | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/library/status_handler.h b/library/status_handler.h index c3a016d5..a7984790 100644 --- a/library/status_handler.h +++ b/library/status_handler.h @@ -8,7 +8,7 @@ #define STATUSHANDLER_H_INCLUDED #include <wx/string.h> -#include "../shared/zstring.h" +#include <string> #include "../shared/int64.h" const int UI_UPDATE_INTERVAL = 100; //perform ui updates not more often than necessary, 100 seems to be a good value with only a minimal performance loss @@ -18,21 +18,6 @@ void updateUiNow(); //do the updating //interfaces for status updates (can be implemented by GUI or Batch mode) -//overwrite virtual methods for respective functionality - -class ErrorHandler -{ -public: - ErrorHandler() {} - virtual ~ErrorHandler() {} - - enum Response - { - IGNORE_ERROR = 10, - RETRY - }; - virtual Response reportError(const Zstring& errorMessage) = 0; -}; //report status during comparison and synchronization @@ -51,21 +36,29 @@ struct ProcessCallback //these methods have to be implemented in the derived classes to handle error and status information virtual void initNewProcess(int objectsTotal, zen::Int64 dataTotal, Process processID) = 0; //informs about the total amount of data that will be processed from now on - virtual void updateProcessedData(int objectsProcessed, zen::Int64 dataProcessed) = 0; //called periodically after data was processed - virtual void reportInfo(const Zstring& text) = 0; + //called periodically after data was processed: expected(!) to update GUI! + virtual void reportInfo(const wxString& text) = 0; - //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events - virtual void forceUiRefresh() = 0; + //note: this one must NOT throw in order to properly allow undoing setting of statistics! + //it is in general paired with a call to requestUiRefresh() to compensate! + virtual void updateProcessedData(int objectsProcessed, zen::Int64 dataProcessed) = 0; //throw() - virtual void requestUiRefresh(bool allowExceptions = true) = 0; //opportunity to abort must be implemented in a frequently executed method like requestUiRefresh() + //opportunity to abort must be implemented in a frequently executed method like requestUiRefresh() + virtual void requestUiRefresh() = 0; //throw ? - virtual bool abortIsRequested() = 0; //thanks to Windows C-Api not supporting exceptions we need this one... + //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events + virtual void forceUiRefresh() = 0; //error handling: - virtual ErrorHandler::Response reportError(const wxString& errorMessage) = 0; //recoverable error situation - virtual void reportFatalError(const wxString& errorMessage) = 0; //non-recoverable error situation, implement abort! - virtual void reportWarning (const wxString& warningMessage, bool& warningActive) = 0; + enum Response + { + IGNORE_ERROR = 10, + RETRY + }; + virtual Response reportError (const wxString& errorMessage) = 0; //recoverable error situation + virtual void reportFatalError(const wxString& errorMessage) = 0; //non-recoverable error situation, implement abort! + virtual void reportWarning (const wxString& warningMessage, bool& warningActive) = 0; }; @@ -83,18 +76,18 @@ class StatusHandler : public ProcessCallback, public AbortCallback public: StatusHandler() : abortRequested(false) {} - virtual void requestUiRefresh(bool allowExceptions) + virtual void requestUiRefresh() { if (updateUiIsAllowed()) //test if specific time span between ui updates is over forceUiRefresh(); - if (abortRequested && allowExceptions) + if (abortRequested) abortThisProcess(); //abort can be triggered by requestAbortion() } - virtual void requestAbortion() { abortRequested = true; } //this does NOT call abortThisProcess immediately, but when appropriate (e.g. async. processes finished) - virtual bool abortIsRequested() { return abortRequested; } virtual void abortThisProcess() = 0; + virtual void requestAbortion() { abortRequested = true; } //this does NOT call abortThisProcess immediately, but when appropriate (e.g. async. processes finished) + bool abortIsRequested() { return abortRequested; } private: bool abortRequested; |