diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
commit | bd6336c629841c6db3a6ca53a936d629d34db53b (patch) | |
tree | 3721ef997864108df175ce677a8a7d4342a6f1d2 /library/status_handler.h | |
parent | 4.0 (diff) | |
download | FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2 FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip |
4.1
Diffstat (limited to 'library/status_handler.h')
-rw-r--r-- | library/status_handler.h | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/library/status_handler.h b/library/status_handler.h deleted file mode 100644 index 1282f9f1..00000000 --- a/library/status_handler.h +++ /dev/null @@ -1,102 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#ifndef STATUSHANDLER_H_INCLUDED -#define STATUSHANDLER_H_INCLUDED - -#include <wx/string.h> -#include <string> -#include "../shared/int64.h" - -const int UI_UPDATE_INTERVAL = 100; //unit: [ms]; perform ui updates not more often than necessary, 100 seems to be a good value with only a minimal performance loss - -bool updateUiIsAllowed(); //test if a specific amount of time is over -void updateUiNow(); //do the updating - - -//interfaces for status updates (can be implemented by GUI or Batch mode) - - -//report status during comparison and synchronization -struct ProcessCallback -{ - virtual ~ProcessCallback() {} - - //identifiers of different phases - enum Process - { - PROCESS_NONE = 10, - PROCESS_SCANNING, - PROCESS_COMPARING_CONTENT, - PROCESS_SYNCHRONIZING - }; - - //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 - - //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() - - //opportunity to abort must be implemented in a frequently executed method like requestUiRefresh() - virtual void requestUiRefresh() = 0; //throw ? - - //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events - virtual void forceUiRefresh() = 0; - - //called periodically after data was processed: expected(!) to request GUI update - virtual void reportStatus(const wxString& text) = 0; //status info only, should not be logged! - - //called periodically after data was processed: expected(!) to request GUI update - virtual void reportInfo(const wxString& text) = 0; - - virtual void reportWarning(const wxString& warningMessage, bool& warningActive) = 0; - - //error handling: - 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 -}; - - -//gui may want to abort process -struct AbortCallback -{ - virtual ~AbortCallback() {} - virtual void requestAbortion() = 0; -}; - - -//actual callback implementation will have to satisfy "process" and "gui" -class StatusHandler : public ProcessCallback, public AbortCallback -{ -public: - StatusHandler() : abortRequested(false) {} - - virtual void requestUiRefresh() - { - if (updateUiIsAllowed()) //test if specific time span between ui updates is over - forceUiRefresh(); - - if (abortRequested) - abortThisProcess(); //abort can be triggered by requestAbortion() - } - - 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; -}; - - - -#endif // STATUSHANDLER_H_INCLUDED |