FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Graph_private.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 GRAPH_PRIVATE
20 #define GRAPH_PRIVATE
21 
22 #include "ImageOperation.hpp"
23 
24 #include <map>
25 #include <list>
26 
27 namespace boost {
28 class thread;
29 }
30 
31 namespace FotoSHOCKcore {
32 
33 class GraphManager;
34 class GraphNode;
35 
37  friend class GraphManager;
38  friend class GraphNode;
39 
40  public:
41  ~Graph_private();
42 
43  protected:
44  Graph_private();
45 
47 
50  void recalculate(GraphNode* node);
51 
52  // TODO: doc
53  void interruptRecalculate();
54 
56 
63  bool tryEnable(GraphNode* node);
64 
66 
77  void confirmOperation(GraphNode* node);
79 
86  boost::shared_ptr<UpdateInfo> addROI(GraphNode* node, UpdateInfo ROI);
90  boost::shared_ptr<UpdateInfo> addROI(GraphNode* node, ROIinfo ROI);
94  boost::shared_ptr<UpdateInfo> addROI(GraphNode* node, unsigned int x, unsigned int y, unsigned int sizeX, unsigned int sizeY, const int mipmapLevel = 0);
95 
97 
103  vector<boost::shared_ptr<UpdateInfo> >::iterator deleteROI(boost::shared_ptr<UpdateInfo> ROI);
104 // private:
106  vector<GraphNode*> m_roots;
108  unsigned int m_tileExtent;
109 
111  unsigned int m_nodeIDcounter;
112 
114 
117  std::map<uint64_t, ImageOperationDescriptor*> m_registeredOperations;
118 
120 
124  boost::thread* m_recalculateThread;
125 
126  double m_timingSheer;
127  double m_timingCurvature;
128 
130 
133  void recalculate_impl(GraphNode* node);
134 
136 
146  // TODO: reenable
147  void checkFormat(ImageOperationDescriptor* operation, vector<GraphNode*>& parents, vector<GraphNode*>& children);
148 
150 
157  void createCache(vector<GraphNode*>& parents, GraphNode* node, bool allocateTiles = true);
158 
160 
166  void removeNode(vector<GraphNode*>& vect, GraphNode* node);
167 
169 
173  void topologicalSort(GraphNode* node, std::list<GraphNode*>& sorted);
174  void topologicalSort_impl(GraphNode* node, std::list<GraphNode*>& sorted);
175 
177 
218  void updateParentsCache(GraphNode* node);
219 
221 
229  void updateChildrenBuffer(GraphNode* node);
230 
232  void cleanupVisited(GraphNode* node);
233 
234  void addROI_impl(GraphNode* node, boost::shared_ptr<UpdateInfo> ROI);
235 
236  // addition of ROI is missed in case when the user doesn't specify parents
237  // but it should never happen, because otherwise a new root would be created
239 
249  void insertROIForNodes(GraphNode* node, GraphNode* parent, GraphNode* child);
251 
261  void insertROIForNodes(GraphNode* node, vector<GraphNode*>& parents, GraphNode* child);
262 
264  void updateDistance(GraphNode* node);
266  double computeTimeLimit(double a, double b, double distance);
267 
269 
278  void cleanupCache();
279  void cleanupCache_impl(GraphNode* node, float time);
280 
283 
285 
291  void disableChildren(GraphNode* node, bool cleanBuffer);
292 };
293 
294 }
295 
296 #endif