VR-Forces 4.2 Class Documentation
pagingFeatureSet.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #pragma once
6 
7 #include <features/feature.h>
8 #include <features/featureSet.h>
11 
12 #include <tbb/queuing_rw_mutex.h>
13 #include <tbb/spin_rw_mutex.h>
14 
15 #include <boost/logic/tribool.hpp>
16 
17 namespace MAKVRinTerra
18 {
19  class DtUnusedFeatureTileTracker;
20  class DtSharedMemoryFeaturesDebugDrawer;
21 
22  template <typename FS>
24  {
25  public:
32 
33  typedef FS FeatureSet;
34  typedef typename FeatureSet::Feature Feature;
35  typedef typename FeatureSet::ForEachFunction ForEachFunction;
36 
37  typedef boost::shared_ptr<DtPagingFeatureSet> Ptr;
38  typedef boost::shared_ptr<Subset> SubsetPtr;
39  typedef boost::shared_ptr<const Subset> SubsetCPtr;
40  typedef boost::shared_ptr<Tile> TilePtr;
41  typedef boost::shared_ptr<const Tile> TileCPtr;
42  typedef boost::weak_ptr<Tile> TileWeakPtr;
43  typedef boost::shared_ptr<Grid> GridPtr;
44  typedef boost::shared_ptr<const Grid> GridCPtr;
45  typedef boost::shared_ptr<Leaf> LeafPtr;
46  typedef boost::shared_ptr<const Leaf> LeafCPtr;
47 
48  typedef std::vector<TilePtr> TileVector;
49 
50  typedef boost::function<void (const FeatureSet&, DtFeatureGeometry)> Callback;
51 
52  struct Config
53  {
54  typedef boost::shared_ptr<Config> Ptr;
56 
58  boost::scoped_ptr<FeatureSet> inputFeatureSet;
60  boost::weak_ptr<Queue> taskQueue;
64 
65  explicit Config(
66  FeatureSet*,
68  Callback callback = Callback(),
69  boost::shared_ptr<Queue> queue = boost::shared_ptr<Queue>());
70 
71  int loadLevel() const;
72  void setLoadLevel(const Subset&);
73  };
74 
75  explicit DtPagingFeatureSet(TilePtr, bool cache=true);
76 
77  std::string label() const;
78  void forEachFeature(ForEachFunction, DtWaitType) const;
79  void forEachFeatureParallel(ForEachFunction func, DtWaitType) const;
80  FeatureSet* filter(const DtQuery&, DtLoadType) const;
81  DtPagingFeatureSet* clone() const;
82  bool loaded(double) const;
83  unsigned numberOfFeatures() const;
84  bool empty() const;
85 
86  SubsetPtr subset() const;
87 
88  protected:
89  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
90 
91  typedef tbb::spin_mutex Mutex;
92 
94  mutable Mutex myMutex;
97  };
98 
99  template <typename FS>
100  class DtPagingFeatureSet<FS>::Subset : virtual public FS
101  {
102  public:
103  virtual DtProj::Bounds bounds() const = 0;
104  virtual DtFeatureGeometry::Area tileGeometry() const = 0;
105  virtual SubsetPtr parent() const = 0;
106  virtual int level() const = 0;
107 
108  virtual void drawTiles(DtSharedMemoryFeaturesDebugDrawer&) const = 0;
109 
110  virtual SubsetPtr getTiles(
111  typename FS::List&, boost::optional<DtFeatureGeometry>) = 0;
112 
113  virtual boost::optional<unsigned> sizeEstimate() const = 0;
114  virtual void updateStats();
115  };
116 
117  template <typename FS>
119  {
120  public:
121  using Subset::getTiles;
122 
123  virtual void forEachFeature(ForEachFunction, DtWaitType) const = 0;
124  virtual void forEachFeatureParallel(ForEachFunction, DtWaitType) const = 0;
125 
126  virtual SubsetPtr getTiles(
127  typename FS::List&, boost::optional<DtFeatureGeometry>, unsigned startLevel) = 0;
128 
129  bool index();
130  virtual bool index(const FS&) = 0;
131 
132  DtProj::Bounds bounds() const;
133  DtFeatureGeometry::Area tileGeometry() const;
134  SubsetPtr parent() const;
135 
136  const Config& config() const;
137  const FeatureSet& input() const;
138  int level() const;
139 
140  protected:
141  Tile(GridPtr parent, unsigned i);
142  Tile(typename Config::Ptr, const DtProj::Bounds&, int level);
143 
144  const typename Config::Ptr myInfo;
145  const int myLevel;
146 
148 
151  };
152 
153  template <typename FS>
155  : public DtPagingFeatureSet<FS>::Tile
156  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
157  {
158  public:
159  std::string label() const;
160 
163 
164  SubsetPtr getTiles(typename FS::List&, boost::optional<DtFeatureGeometry>);
165  SubsetPtr getTiles(
166  typename FS::List&, boost::optional<DtFeatureGeometry>, unsigned startLevel);
167 
168  void drawTiles(DtSharedMemoryFeaturesDebugDrawer&) const;
169 
170  boost::optional<unsigned> sizeEstimate() const;
171  void updateStats();
172 
173  virtual TilePtr getSubtile(unsigned i, boost::tribool forceLeaf) const = 0;
174  virtual TilePtr getLoadedSubtile(unsigned i) const = 0;
175 
176  FS* clone() const;
177 
178  bool loaded(double) const;
179  unsigned numberOfFeatures() const;
180  bool empty() const;
181 
182  DtProj::Bounds computeSubtileBounds(unsigned i) const;
183 
184  Grid(typename Config::Ptr cfg, const DtProj::Bounds&, unsigned level);
185 
186  protected:
187  struct ParallelCaller;
188 
189  Grid(GridPtr parent, unsigned i);
190 
191  typedef tbb::spin_rw_mutex Mutex;
192 
193  mutable Mutex myMutex;
194 
196  boost::optional<unsigned> mySizeEstimate;
197  };
198 
199  template <typename FS>
201  {
202  public:
203  WeakGrid(typename Config::Ptr cfg, const DtProj::Bounds&, unsigned level);
204 
205  bool index(const FS&);
206 
207  TilePtr getSubtile(unsigned i, boost::tribool forceLeaf) const;
208  TilePtr getLoadedSubtile(unsigned i) const;
209 
210 
211  protected:
212  WeakGrid(GridPtr parent, unsigned i);
213 
214  TileWeakPtr mySubtiles[9];
215  };
216 
217  template <typename FS>
219  : public DtPagingFeatureSet<FS>::Tile
220  , public DtQueueLoadingFeatureSet<FS>
221  {
222  public:
223  typedef std::vector<typename Feature::CPtr> FeatureVector;
225 
228  bool loaded(double = 0) const;
229  unsigned numberOfFeatures() const;
230 
231  bool index(const FS&);
232 
233  SubsetPtr getTiles(
234  typename FS::List&, boost::optional<DtFeatureGeometry>);
235  SubsetPtr getTiles(
236  typename FS::List&, boost::optional<DtFeatureGeometry>, unsigned startLevel);
237 
238  void drawTiles(DtSharedMemoryFeaturesDebugDrawer&) const;
239 
240  boost::optional<unsigned> sizeEstimate() const;
241 
242  FS* clone() const;
243 
244  std::string label() const;
245 
246  Leaf(GridPtr parent, unsigned i);
247 
248  LeafPtr shared_from_this();
249  LeafCPtr shared_from_this() const;
250 
251  void unload();
252 
253  protected:
254  void start();
255  bool run(const typename DtAsyncLoadingFeatureSet<FS>::Ptr&);
256  FS* createFeatureSet(FS*) const;
257  };
258 
259  template <typename FS>
261  {
262  public:
263  explicit LoadingFeatureSet(LeafPtr);
265 
266  std::string label() const;
269  LoadingFeatureSet* clone() const;
270 
271  private:
272  struct WrapWithPagingFeature;
273  class PagingFeature;
274 
275  explicit LoadingFeatureSet(const LoadingFeatureSet&);
276 
278  };
279 }

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)