VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
14 #include <features/tileFeature.h>
15 
17 
18 #include <tbb/queuing_rw_mutex.h>
19 #include <tbb/spin_rw_mutex.h>
20 
21 #include <boost/logic/tribool.hpp>
22 
23 namespace MAKVRinTerra
24 {
25  class DtUnusedFeatureTileTracker;
26 
27  template <typename FS>
29 
38  template <typename FS>
40  : public DtFeatureSetWrapper<FS, boost::shared_ptr, DtPagingFeatureSetSubset<FS> >
41  , public DtObjectDebugger< DtPagingFeatureSet<FS> >
42  {
43  public:
44  typedef DtFeatureSetWrapper<FS, boost::shared_ptr, DtPagingFeatureSetSubset<FS> > Base;
45 
46  using Base::filter;
47 
48  template <template <class> class PtrT> class DT_DLL_features GridTemplate;
51  class DT_DLL_features WeakGrid;
53 
54  typedef FS FeatureSet;
55  typedef typename FeatureSet::Feature Feature;
56  typedef typename FeatureSet::ForEachFunction ForEachFunction;
57 
58  typedef boost::shared_ptr<DtPagingFeatureSet> Ptr;
59  typedef boost::shared_ptr<Subset> SubsetPtr;
60  typedef boost::shared_ptr<const Subset> SubsetCPtr;
61  typedef boost::shared_ptr<Grid> GridPtr;
62  typedef boost::shared_ptr<const Grid> GridCPtr;
63  typedef boost::shared_ptr<Leaf> LeafPtr;
64  typedef boost::shared_ptr<const Leaf> LeafCPtr;
65 
69  {
70  public:
71  typedef boost::shared_ptr<Config> Ptr;
73 
75  boost::shared_ptr<FeatureSet> inputFeatureSet;
76 
81 
83  boost::weak_ptr<Queue> taskQueue;
84 
87  boost::shared_ptr<DtFeatureSet::Source> tileFeatures;
88 
90  explicit Config(FeatureSet*);
91 
93  explicit Config(const Config& cfg)
94  : inputFeatureSet(cfg.inputFeatureSet)
95  , unusedTileTracker(cfg.unusedTileTracker)
96  , taskQueue(cfg.taskQueue)
97  , tileFeatures(cfg.tileFeatures)
98  {
99  static_cast<DtTerrainInterfaceConfig&>(*this) = cfg;
100  }
101  };
102 
104 
105  static DtPagingFeatureSet* Make(Config* cfg, const DtProj::Bounds& bounds)
106  {
107  typename Config::Ptr c(cfg);
108  SubsetPtr parentTile(new Grid(c, bounds));
109  return new DtPagingFeatureSet(parentTile);
110  }
111 
112  static DtPagingFeatureSet* Make(const Config& cfg, const DtProj::Bounds& bounds)
113  {
114  return Make(new Config(cfg), bounds);
115  }
117 
118  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
119  DtPagingFeatureSet* clone() const;
120  bool loaded(double) const;
121 
122  protected:
123  explicit DtPagingFeatureSet(const SubsetCPtr&);
124  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
125 
126  typedef tbb::spin_mutex Mutex;
127 
128  mutable Mutex myMutex;
130  };
131 
132  template <typename FS>
134  : virtual public FS
135  , public DtObjectDebugger< DtPagingFeatureSetSubset<FS> >
136  {
137  public:
142 
144 
145  const Config& config() const { return *myInfo; }
146  const FS& input() const { return *config().inputFeatureSet; }
147  DtProj::Bounds bounds() const { return myBounds; }
149  SubsetPtr parent() const { return myParent; }
150  int level() const { return myLevel; }
151 
152  virtual FS* filterCache(
153  const DtQuery&,
154  const boost::optional<DtFeatureGeometry>&,
155  DtLoadType,
156  SubsetCPtr& highestSubset,
157  unsigned indexLevel = 0) const = 0;
158 
159  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
160 
161  virtual boost::optional<unsigned> sizeEstimate() const = 0;
162  virtual void updateStats();
163 
164  protected:
165  DtPagingFeatureSetSubset(const GridCPtr& parent, unsigned i);
166  DtPagingFeatureSetSubset(const typename Config::Ptr&, const DtProj::Bounds&);
167 
168  const typename Config::Ptr myInfo;
169  const int myLevel;
170 
172 
175  };
176 
177  template <typename FS>
178  template <template <class> class PtrT>
180  : public DtPagingFeatureSet<FS>::Subset
181  {
182  public:
183  struct Tile
184  {
185  explicit Tile(const DtProj::Bounds& b, unsigned i);
186 
189 
190  DtFeatureSetWrapper<FS, PtrT, Subset> subtile;
191  };
192 
193  typedef typename FS::DetachCallback DetachCallback;
194  typedef typename FS::LoadedCallback LoadedCallback;
195 
196  std::string label() const;
197 
198  void forEachFeatureParallel(const ForEachFunction&) const;
199  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
200 
201  boost::optional<unsigned> sizeEstimate() const;
202  void updateStats();
203 
204  const DtProj::Bounds& subBounds(unsigned) const;
205  const DtFeatureGeometry::Area& subGeometry(unsigned) const;
206 
207  Tile& getSubtile(unsigned);
208  const Tile& getSubtile(unsigned) const;
209 
210  bool loaded(double) const;
211  DetachCallback addLoadedCallback(const LoadedCallback&) const;
212  unsigned numberOfFeatures() const;
213  bool empty() const;
214 
215  GridTemplate(const typename Config::Ptr& cfg, const DtProj::Bounds&);
216 
217  protected:
218  struct Detacher;
219 
220  GridTemplate(const GridCPtr& parent, unsigned i);
221 
222  typedef tbb::spin_rw_mutex SizeMutex;
224 
229 
230  boost::optional<unsigned> mySizeEstimate;
231  const bool myEmptyFlag;
232  };
233 
234  template <typename FS>
236  : public DtPagingFeatureSet<FS>::template GridTemplate<boost::weak_ptr>
237  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
238  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Grid>
239  {
240  public:
241  FS* filterCache(
242  const DtQuery&,
243  const boost::optional<DtFeatureGeometry>&,
244  DtLoadType,
245  SubsetCPtr& highestSubset,
246  unsigned indexLevel) const;
247 
248  FS* clone() const;
249 
250  Grid(const typename Config::Ptr& cfg, const DtProj::Bounds&);
251 
252  protected:
253  virtual bool makeLeaf(unsigned) const;
254 
255  Grid(const GridCPtr& parent, unsigned i);
256  };
257 
258  template <typename FS>
260  : public DtPagingFeatureSet<FS>::Subset
261  , public DtQueueLoadingFeatureSet<FS>
262  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Leaf>
263  {
264  public:
265  typedef typename FS::ForEachFunction ForEachFunction;
266  typedef typename FS::DetachCallback DetachCallback;
267 
268  typedef std::vector<typename Feature::CPtr> FeatureVector;
269 
270  ~Leaf();
271 
272  bool loaded(double = 0) const;
273  unsigned numberOfFeatures() const;
274  bool empty() const;
275  void forEachFeatureParallel(const ForEachFunction&) const;
276  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
277 
278  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
279 
280  FS* filterCache(
281  const DtQuery&,
282  const boost::optional<DtFeatureGeometry>&,
283  DtLoadType,
284  SubsetCPtr& highestSubset,
285  unsigned indexLevel) const;
286 
287  boost::optional<unsigned> sizeEstimate() const;
288 
289  FS* clone() const;
290 
291  std::string label() const;
292 
293  Leaf(const GridCPtr& parent, unsigned i);
294 
295  LeafPtr shared_from_this();
296  LeafCPtr shared_from_this() const;
297 
298  bool unload();
299 
300  protected:
301  void makeTileFeature(const DtFeatureGeometry& geom, unsigned color);
302 
303  void start(bool wait);
304  bool run(bool wait);
305  FS* createFeatureSet(FS*) const;
306  void inputLoadedCallback();
307 
308  typedef tbb::spin_mutex TileFeatureMutex;
310  std::auto_ptr<DtTileFeature> myTileFeature;
311  };
312 }
313 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)