00001
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
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
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
00136
00137
00138
00139
00140
00141
00142
00143
00144
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
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
00181
00182 private:
00183 AppBase::ProgressDisplay* m_progressDisplay;
00184 bool m_wasCancelled;
00185
00186 };
00187
00188
00189 };
00190 #endif // _H