Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages
hugin_base/algorithm/PanoramaAlgorithm.h
Go to the documentation of this file.00001 // -*- c-basic-offset: 4 -*- 00031 #ifndef _ALGORITHM_PANORAMAALGORITHM_H 00032 #define _ALGORITHM_PANORAMAALGORITHM_H 00033 00034 #include <hugin_shared.h> 00035 #include <appbase/ProgressDisplay.h> 00036 00037 00038 namespace HuginBase { 00039 00040 class PanoramaData; 00041 00042 00046 class IMPEX PanoramaAlgorithm 00047 { 00048 00049 protected: 00051 PanoramaAlgorithm(PanoramaData& panorama) 00052 : o_panorama(panorama), o_successful(false) 00053 { }; 00054 00055 public: 00057 virtual ~PanoramaAlgorithm() {}; 00058 00059 00060 public: 00062 virtual bool modifiesPanoramaData() const =0; 00063 00065 virtual bool hasRunSuccessfully() 00066 { 00067 return o_successful; 00068 } 00069 00071 virtual void run() 00072 { 00073 o_successful = runAlgorithm(); 00074 } 00075 00076 #if 0 00077 00078 template<class AlgorithmClass> 00079 AlgorithmClass& runMe() 00080 { 00081 AlgorithmClass& THIS = static_cast<AlgorithmClass&>(*this); 00082 THIS.run(); 00083 return THIS; 00084 } 00085 #endif 00086 00090 virtual bool runAlgorithm() =0; 00091 00092 /* 00093 * Here is the informal interface guidelines that you should follow when 00094 * you subclass from this class: 00095 * 00096 * 1. You should provide [ SomeType getSomeResult() ] methods if there 00097 * is any result from the algorithm. 00098 * 00099 * 2. For complicated algorithms, you can have [ MyErrorEnum getError() ] 00100 * that returns error. 00101 * 00102 * 3. You can optionaly implement your algorithm as 00103 * [ static SomeType executeMyAlgorithm(PanoramaData& panorama, all parameters) ]. 00104 * 00105 */ 00106 00107 protected: 00108 PanoramaData& o_panorama; 00109 bool o_successful; 00110 00111 }; 00112 00113 00114 00118 class IMPEX TimeConsumingPanoramaAlgorithm : public PanoramaAlgorithm 00119 { 00120 00121 protected: 00123 TimeConsumingPanoramaAlgorithm(PanoramaData& panorama, AppBase::ProgressDisplay* progressDisplay = NULL) 00124 : PanoramaAlgorithm(panorama), 00125 m_progressDisplay(progressDisplay), m_wasCancelled(false) 00126 { }; 00127 00128 public: 00130 virtual ~TimeConsumingPanoramaAlgorithm() {}; 00131 00132 00133 public: 00134 /* 00135 * Please follow the same guideline as the PanoramaAlgorithm class, but with: 00136 * 00137 * 3. should now be 00138 * [ static SomeType executeMyAlgorithm(PanoramaData& panorama, ProgressDisplay* progressDisplay, all parameters) ] 00139 * instead. 00140 * 00141 */ 00142 00143 00144 // -- access to the ProgressDisplay -- 00145 00146 protected: 00148 virtual AppBase::ProgressDisplay* getProgressDisplay() const 00149 { return m_progressDisplay; }; 00150 00152 virtual bool hasProgressDisplay() const 00153 { return getProgressDisplay() != NULL; }; 00154 00155 00156 // -- cancelling process -- 00157 00158 public: 00160 virtual bool wasCancelled() const 00161 { return m_wasCancelled; }; 00162 00163 protected: 00167 virtual void cancelAlgorithm() 00168 { 00169 m_wasCancelled = true; 00170 algorithmCancelled(); 00171 } 00172 00177 virtual void algorithmCancelled() {}; 00178 00179 00180 // -- private variables -- 00181 00182 private: 00183 AppBase::ProgressDisplay* m_progressDisplay; 00184 bool m_wasCancelled; 00185 00186 }; 00187 00188 00189 }; // namespace 00190 #endif // _H
1.3.9.1