FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
ImageOperation.hpp
1 /*
2  * Copyright 2011, 2012 Lukas Jirkovsky
3  *
4  * This file is part of FotoSHOCKcore.
5  *
6  * FotoSHOCKcore is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * FotoSHOCKcore is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with FotoSHOCKcore. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef IMAGEOPERATION_H
20 #define IMAGEOPERATION_H
21 
22 #include "MipMap.hpp"
23 #include "UpdateInfo.hpp"
24 #include "FixedArray.hpp"
25 #include "serialization/XmlSerializer.hpp"
26 
27 #include <boost/shared_ptr.hpp>
28 #include <vector>
29 #include <utility>
30 
31 using std::vector;
32 
33 namespace FotoSHOCKcore {
34 
36 
44 class InputProto {
45  public:
47 
55  int addInput(PixelData dataFormat);
56 
58 
61  const std::size_t size() const;
62  private:
63  std::vector<PixelData> inputDataFormats;
64 };
65 
67 
73 class OutputProto {
74  public:
76 
80  int addOutput(PixelData dataFormat);
82 
85  const std::size_t size() const;
86  private:
87  std::vector<PixelData> outputDataFormats;
88 };
89 
92 
94 
106  public:
109 
111  virtual ~ImageOperationDescriptor();
112 
118 
127 
133  };
134 
136 
141  virtual const char* name() = 0;
143 
146  virtual const char* description() = 0;
148 
157  uint64_t id();
159 
168  virtual InputProto inputPrototype();
170 
181  // TODO: support multiple outputs
182  virtual OutputProto outputPrototype();
183 
185 
192 
194 
201  virtual ImageOperation* operation() = 0;
202 
203  // TODO: versioning
204 };
205 
207 
215  public:
216  friend class GraphNode;
217 
219 
223  ImageOperation();
225  virtual ~ImageOperation();
226 
228 
231  GraphNode* getOwnerNode() const;
232 
234 
245  virtual void initialize();
246 
248 
258  virtual bool isPrepared();
259 
261 
276  virtual void runOperation(const Inputs& sources, const Outputs& dest, vector<UpdateInfo>& ROI, const long stamp) = 0;
277 
279 
287  virtual bool updateROI(UpdateInfo& currentROI, UpdateInfo& parentROI);
288 
290 
303  boost::shared_ptr<UpdateInfo> requestROI(boost::shared_ptr<UpdateInfo> currentROI);
304 
306 
315  virtual void serialize(XmlSerializer& serializer);
316 
318 
321  virtual void deserialize(XmlSerializer& serializer);
322  protected:
324 
329  void setOwnerNode(GraphNode* node);
330  private:
331  // used to access the ROI and force redraw
332  GraphNode* m_parentNode;
333 };
334 
335 }
336 
337 #endif