VR-Forces Development_Version 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  const DtProj::Bounds::LineSegment* = 0,
158  unsigned indexLevel = 0) const = 0;
159 
160  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
161 
162  virtual boost::optional<unsigned> sizeEstimate() const = 0;
163  virtual void updateStats();
164 
165  protected:
166  DtPagingFeatureSetSubset(const GridCPtr& parent, unsigned i);
167  DtPagingFeatureSetSubset(const typename Config::Ptr&, const DtProj::Bounds&);
168 
169  const typename Config::Ptr myInfo;
170  const int myLevel;
171 
173 
176  };
177 
178  template <typename FS>
179  template <template <class> class PtrT>
181  : public DtPagingFeatureSet<FS>::Subset
182  {
183  public:
184  struct Tile
185  {
186  explicit Tile(const DtProj::Bounds& b, unsigned i);
187 
190 
191  DtFeatureSetWrapper<FS, PtrT, Subset> subtile;
192  };
193 
194  typedef typename FS::DetachCallback DetachCallback;
195  typedef typename FS::LoadedCallback LoadedCallback;
196 
197  std::string label() const;
198 
199  void forEachFeatureParallel(const ForEachFunction&) const;
200  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
201 
202  boost::optional<unsigned> sizeEstimate() const;
203  void updateStats();
204 
205  const DtProj::Bounds& subBounds(unsigned) const;
206  const DtFeatureGeometry::Area& subGeometry(unsigned) const;
207 
208  Tile& getSubtile(unsigned);
209  const Tile& getSubtile(unsigned) const;
210 
211  bool loaded(double) const;
212  DetachCallback addLoadedCallback(const LoadedCallback&) const;
213  unsigned numberOfFeatures() const;
214  bool elided() const;
215  bool empty() const;
216 
217  GridTemplate(const typename Config::Ptr& cfg, const DtProj::Bounds&);
218 
219  protected:
220  struct Detacher;
221 
222  GridTemplate(const GridCPtr& parent, unsigned i);
223 
224  typedef tbb::spin_rw_mutex SizeMutex;
226 
231 
232  boost::optional<unsigned> mySizeEstimate;
233  const bool myEmptyFlag;
234  };
235 
236  template <typename FS>
238  : public DtPagingFeatureSet<FS>::template GridTemplate<boost::weak_ptr>
239  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
240  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Grid>
241  {
242  public:
243  FS* filterCache(
244  const DtQuery&,
245  const boost::optional<DtFeatureGeometry>&,
246  DtLoadType,
247  SubsetCPtr& highestSubset,
249  unsigned indexLevel) const;
250 
251  FS* clone() const;
252 
253  Grid(const typename Config::Ptr& cfg, const DtProj::Bounds&);
254 
255  protected:
256  virtual bool makeLeaf(unsigned) const;
257 
258  Grid(const GridCPtr& parent, unsigned i);
259  };
260 
261  template <typename FS>
263  : public DtPagingFeatureSet<FS>::Subset
264  , public DtQueueLoadingFeatureSet<FS>
265  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Leaf>
266  {
267  public:
268  typedef typename FS::ForEachFunction ForEachFunction;
269  typedef typename FS::DetachCallback DetachCallback;
270 
271  typedef std::vector<typename Feature::CPtr> FeatureVector;
272 
273  ~Leaf();
274 
275  bool loaded(double = 0) const;
276  unsigned numberOfFeatures() const;
277  bool elided() const;
278  void forEachFeatureParallel(const ForEachFunction&) const;
279  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
280 
281  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
282 
283  FS* filterCache(
284  const DtQuery&,
285  const boost::optional<DtFeatureGeometry>&,
286  DtLoadType,
287  SubsetCPtr& highestSubset,
289  unsigned indexLevel) const;
290 
291  boost::optional<unsigned> sizeEstimate() const;
292 
293  FS* clone() const;
294 
295  std::string label() const;
296 
297  Leaf(const GridCPtr& parent, unsigned i);
298 
299  LeafPtr shared_from_this();
300  LeafCPtr shared_from_this() const;
301 
302  bool unload();
303 
304  protected:
305  void makeTileFeature(const DtFeatureGeometry& geom, unsigned color);
306 
307  void start(bool wait);
308  bool run(bool wait);
309  FS* createFeatureSet(FS*) const;
310  void inputLoadedCallback();
311 
312  typedef tbb::spin_mutex TileFeatureMutex;
314  std::auto_ptr<DtTileFeature> myTileFeature;
315  };
316 }
317 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)