eLynx SDK
v3.0.1 C++ image processing API reference |
00001 //============================================================================ 00002 // ProgressNotifier.h Core.Component package 00003 //============================================================================ 00004 // Usage : Abstract progress notifier class. 00005 //---------------------------------------------------------------------------- 00006 // Copyright (C) 2006 by eLynx project 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free 00020 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 // 00022 //---------------------------------------------------------------------------- 00023 #ifndef __ProgressNotifier_h__ 00024 #define __ProgressNotifier_h__ 00025 00026 #include "elx/core/CoreLib.h" 00027 #include "elx/core/CoreTypes.h" 00028 #include <stack> 00029 00030 namespace eLynx { 00031 00052 class ExportedByCore ProgressNotifier { 00053 00054 public: 00055 00060 ProgressNotifier(uint32 iPhases = 1, float iSensitivity = 0.01f); 00061 00063 virtual ~ProgressNotifier(); 00064 00068 uint32 GetPhaseCount() const; 00069 00073 float GetSensitivity() const; 00074 00078 void SetSensitivity(float iSensitivity); 00079 00082 float GetCurrentProgress() const; 00083 00088 uint32 GetCurrentPhase() const; 00089 00094 void SetProgress(float iProgress, uint32 iPhase = 0); 00095 00096 void Log(const char * iprString, uint32 iPhase = 0); 00097 00107 void PushCurrentPhase(bool iIncrement); 00108 00110 void PopCurrentPhase(); 00111 00115 void RequestCancel(); 00116 00118 bool IsCanceled() const { return _Canceled; } 00119 00120 protected: 00121 00127 virtual void Notify(float iProgress, uint32 iPhase); 00128 virtual void Notify(const char * iprString, uint32 iPhase); 00129 00130 private: 00131 00134 uint32 GetCurrentPhaseOffset() const; 00135 00137 uint32 _Phases; 00138 00140 uint32 _CurrentPhase; 00141 00143 float _CurrentProgress; 00144 00146 float _LastNotifiedProgress; 00147 00150 float _Sensitivity; 00151 00153 std::stack<uint32> _PhaseOffsetStack; 00154 00156 bool _Canceled; 00157 }; 00158 00159 // for default parameters we define a process notifier doing nothing 00160 extern ExportedByCore ProgressNotifier ProgressNotifier_NULL; 00161 00162 } // namespace eLynx 00163 00164 #endif // __ProgressNotifier_h__