Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoramaAlgorithm.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
31 #ifndef _ALGORITHM_PANORAMAALGORITHM_H
32 #define _ALGORITHM_PANORAMAALGORITHM_H
33 
34 #include <hugin_shared.h>
36 
37 
38 namespace HuginBase {
39 
40  class PanoramaData;
41 
42 
47  {
48 
49  protected:
52  : o_panorama(panorama), o_successful(false)
53  { };
54 
55  public:
57  virtual ~PanoramaAlgorithm() {};
58 
59 
60  public:
62  virtual bool modifiesPanoramaData() const =0;
63 
65  virtual bool hasRunSuccessfully()
66  {
67  return o_successful;
68  }
69 
71  virtual void run()
72  {
73  o_successful = runAlgorithm();
74  }
75 
76 #if 0
77  template<class AlgorithmClass>
79  AlgorithmClass& runMe()
80  {
81  AlgorithmClass& THIS = static_cast<AlgorithmClass&>(*this);
82  THIS.run();
83  return THIS;
84  }
85 #endif
86 
90  virtual bool runAlgorithm() =0;
91 
92  /*
93  * Here is the informal interface guidelines that you should follow when
94  * you subclass from this class:
95  *
96  * 1. You should provide [ SomeType getSomeResult() ] methods if there
97  * is any result from the algorithm.
98  *
99  * 2. For complicated algorithms, you can have [ MyErrorEnum getError() ]
100  * that returns error.
101  *
102  * 3. You can optionaly implement your algorithm as
103  * [ static SomeType executeMyAlgorithm(PanoramaData& panorama, all parameters) ].
104  *
105  */
106 
107  protected:
110 
111  };
112 
113 
114 
119  {
120 
121  protected:
124  : PanoramaAlgorithm(panorama),
125  m_progressDisplay(progressDisplay), m_wasCancelled(false)
126  { };
127 
128  public:
131 
132 
133  public:
134  /*
135  * Please follow the same guideline as the PanoramaAlgorithm class, but with:
136  *
137  * 3. should now be
138  * [ static SomeType executeMyAlgorithm(PanoramaData& panorama, ProgressDisplay* progressDisplay, all parameters) ]
139  * instead.
140  *
141  */
142 
143 
144  // -- access to the ProgressDisplay --
145 
146  protected:
149  { return m_progressDisplay; };
150 
152  virtual bool hasProgressDisplay() const
153  { return getProgressDisplay() != NULL; };
154 
155 
156  // -- cancelling process --
157 
158  public:
160  virtual bool wasCancelled() const
161  { return m_wasCancelled; };
162 
163  protected:
167  virtual void cancelAlgorithm()
168  {
169  m_wasCancelled = true;
170  algorithmCancelled();
171  }
172 
177  virtual void algorithmCancelled() {};
178 
179 
180  // -- private variables --
181 
182  private:
183  AppBase::ProgressDisplay* m_progressDisplay;
185 
186  };
187 
188 
189 }; // namespace
190 #endif // _H
virtual void cancelAlgorithm()
Call this when the algorithm is cancelled.
virtual void run()
runs the algorithm.
virtual AppBase::ProgressDisplay * getProgressDisplay() const
TimeConsumingPanoramaAlgorithm(PanoramaData &panorama, AppBase::ProgressDisplay *progressDisplay=NULL)
[Warning! it keeps the reference to the panorama data!]
Model for a panorama.
Definition: PanoramaData.h:81
#define IMPEX
Definition: hugin_shared.h:39
PanoramaAlgorithm(PanoramaData &panorama)