VR-Forces 4.1 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>
12 
13 #include <tbb/recursive_mutex.h>
14 
15 namespace MAKVRinTerra
16 {
17  class DtUnusedFeatureTileTracker;
18 
19  template <typename F>
21  {
22  public:
27 
28  typedef F Feature;
31 
32  typedef boost::shared_ptr<DtPagingFeatureSet> Ptr;
33  typedef boost::shared_ptr<Tile> TilePtr;
34  typedef boost::weak_ptr<Tile> TileWeakPtr;
35  typedef boost::shared_ptr<Grid> GridPtr;
36  typedef boost::shared_ptr<Leaf> LeafPtr;
37 
38  typedef std::vector<LeafPtr> LeafVector;
39  typedef std::vector<TilePtr> TileVector;
40 
41  typedef boost::function<void (const FeatureSet&, DtFeatureGeometry)> Callback;
42 
43  explicit DtPagingFeatureSet(TilePtr);
44 
45  void forEachFeature(ForEachFunction, DtWaitType) const;
46  void forEachFeatureParallel(ForEachFunction func, DtWaitType) const;
47  FeatureSet* filter(const DtQuery&, DtLoadType) const;
48  DtPagingFeatureSet* clone() const;
49  DtQuery schema() const;
50  bool loaded(double) const;
51  unsigned numberOfFeatures() const;
52 
53  protected:
54  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
55 
57  };
58 
59  template <typename F>
60  class DtPagingFeatureSet<F>::Tile : private boost::noncopyable
61  {
62  public:
63  virtual void forEachLoadedFeature(
64  ForEachFunction, DtWaitType) const = 0;
65  virtual void forEachLoadedFeatureParallel(
66  ForEachFunction, DtWaitType) const = 0;
67 
68  virtual void getAllLoadedTileGeometries(
70 
71  virtual TilePtr getTiles(
72  LeafVector&, boost::optional<DtFeatureGeometry>) = 0;
73 
74  virtual bool loaded(double) const = 0;
75  virtual unsigned numberOfFeatures() const = 0;
76 
77  const DtProj::Bounds& bounds() const;
78  DtFeatureGeometry::Area tileGeometry() const;
79  const FeatureSet& input() const;
80 
81  DtProj::Bounds computeParentBounds() const;
82 
83  GridPtr parent() const;
84 
85  DtQuery schema() const { return mySchema; }
86 
87  protected:
88  struct GlobalInfo
89  {
90  typedef boost::shared_ptr<GlobalInfo> Ptr;
92 
94  boost::scoped_ptr<FeatureSet> inputFeatureSet;
97  boost::shared_ptr<Queue> myTaskQueue;
98 
100  Callback load, Callback unload, unsigned maxTasks);
101  };
102 
103  Tile(GridPtr parent, unsigned xindex, unsigned yindex);
104  Tile(typename GlobalInfo::Ptr, const DtProj::Bounds&);
105  explicit Tile(TilePtr child);
106 
107  const typename GlobalInfo::Ptr myInfo;
108 
109  protected:
111 
115  };
116 
117  template <typename F>
119  : public DtPagingFeatureSet<F>::Tile
120  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<F>::Grid>
121  {
122  public:
123  void forEachLoadedFeature(
124  ForEachFunction, DtWaitType) const;
125  void forEachLoadedFeatureParallel(
126  ForEachFunction, DtWaitType) const;
127  void getAllLoadedTileGeometries(DtFeatureGeometry::GeometryVector&) const;
128  TilePtr getTiles(
129  LeafVector&, boost::optional<DtFeatureGeometry>);
130 
131  TilePtr getSubtile(unsigned x, unsigned y);
132 
133  bool loaded(double) const;
134  unsigned numberOfFeatures() const;
135 
136  DtProj::Bounds computeSubtileBounds(unsigned xindex, unsigned yindex) const;
137 
138  Grid(FeatureSet* input, const DtProj::Bounds&, unsigned level,
139  Callback loadCallback = Callback(),
140  Callback unloadCallback = Callback(),
142  unsigned maxTasks = 0);
143 
144  Grid(TilePtr child, unsigned level);
145 
146  private:
147  struct ParallelCaller;
148 
149  Grid(GridPtr parent, unsigned xindex, unsigned yindex);
150 
151  mutable tbb::mutex myMutex;
152  const unsigned myLevel;
153  TileWeakPtr mySubtiles[3][3];
154  };
155 
156  template <typename F>
158  : public DtPagingFeatureSet<F>::Tile
160  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<F>::Leaf>
161  {
162  public:
163  typedef std::vector<typename Feature::CPtr> FeatureVector;
164 
165  ~Leaf();
166 
167  void forEachLoadedFeature(
168  ForEachFunction, DtWaitType) const;
169  void forEachLoadedFeatureParallel(
170  ForEachFunction, DtWaitType) const;
171  void getAllLoadedTileGeometries(DtFeatureGeometry::GeometryVector&) const;
172  TilePtr getTiles(
173  LeafVector&, boost::optional<DtFeatureGeometry>);
174 
175  bool loaded(double) const;
176  unsigned numberOfFeatures() const;
177 
178  bool keep() const;
179  unsigned size() const;
180  boost::shared_ptr<DtUnusedFeatureTileTracker::Trackable> getPtr();
181 
182  Leaf(GridPtr parent, unsigned xindex, unsigned yindex);
183 
184  private:
185  struct CallbackWrapper;
186 
187  void load();
188  void unload();
189 
190  typedef tbb::spin_rw_mutex Mutex;
191 
192  mutable Mutex myMutex;
194  };
195 
196  template <typename F>
198  {
199  public:
200  explicit LoadingFeatureSet(LeafPtr);
201 
204  LoadingFeatureSet* clone() const;
205  DtQuery schema() const;
206  bool loaded(double) const;
207  unsigned numberOfFeatures() const;
208 
209  private:
210  struct WrapWithPagingFeature;
211  class PagingFeature;
212 
213  explicit LoadingFeatureSet(const LoadingFeatureSet&);
214 
217  };
218 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)