VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pagingFeatureSet.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <features/feature.h>
13 #include <features/featureSet.h>
19 #include <features/tileFeature.h>
20 
22 
23 #include <tbb/queuing_rw_mutex.h>
24 #include <tbb/spin_rw_mutex.h>
25 
26 #include <boost/logic/tribool.hpp>
27 
28 namespace MAKVRinTerra
29 {
30  class DtUnusedFeatureTileTracker;
31 
32  template <typename FS>
34 
43  template <typename FS>
45  : public DtFeatureSetWrapper<FS, boost::shared_ptr, DtPagingFeatureSetSubset<FS> >
46 #ifdef DtObjectDebugger_Enable
47  , public DtObjectDebugger< DtPagingFeatureSet<FS> >
48 #endif
49  {
50  public:
52 
53  using Base::filter;
54 
55  template <template <class> class PtrT> class DT_DLL_features GridTemplate;
58  class DT_DLL_features WeakGrid;
60 
61  typedef FS FeatureSet;
62  typedef typename FeatureSet::Feature Feature;
63  typedef typename FeatureSet::ForEachFunction ForEachFunction;
64 
65  typedef boost::shared_ptr<DtPagingFeatureSet> Ptr;
66  typedef boost::shared_ptr<Subset> SubsetPtr;
67  typedef boost::shared_ptr<const Subset> SubsetCPtr;
68  typedef boost::shared_ptr<Grid> GridPtr;
69  typedef boost::shared_ptr<const Grid> GridCPtr;
70  typedef boost::shared_ptr<Leaf> LeafPtr;
71  typedef boost::shared_ptr<const Leaf> LeafCPtr;
72 
76  {
77  public:
78  typedef boost::shared_ptr<Config> Ptr;
80 
82  boost::shared_ptr<FeatureSet> inputFeatureSet;
83 
88 
90  boost::weak_ptr<Queue> taskQueue;
91 
94  boost::shared_ptr<DtFeatureSet::Source> tileFeatures;
95 
97  explicit Config(FeatureSet*);
98 
100  explicit Config(const Config& cfg)
101  : inputFeatureSet(cfg.inputFeatureSet)
102  , unusedTileTracker(cfg.unusedTileTracker)
103  , taskQueue(cfg.taskQueue)
104  , tileFeatures(cfg.tileFeatures)
105  {
106  static_cast<DtTerrainInterfaceConfig&>(*this) = cfg;
107  }
108  };
109 
111 
112  static DtPagingFeatureSet* Make(Config* cfg, const DtProj::Bounds& bounds)
113  {
114  typename Config::Ptr c(cfg);
115  SubsetPtr parentTile(new Grid(c, bounds));
116  return new DtPagingFeatureSet(parentTile);
117  }
118 
119  static DtPagingFeatureSet* Make(const Config& cfg, const DtProj::Bounds& bounds)
120  {
121  return Make(new Config(cfg), bounds);
122  }
124 
125  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
126  DtPagingFeatureSet* clone() const;
127  bool loaded(double) const;
128 
129  bool isCacheable(const boost::optional<DtFeatureGeometry>& area) const;
130  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
131 
132  void cacheData(
133  const boost::optional<DtFeatureGeometry>& area,
134  DtFeatureCacheProgressCallback* progress) const;
135 
136  protected:
137  explicit DtPagingFeatureSet(const SubsetCPtr&);
138  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
139 
140  typedef tbb::spin_mutex Mutex;
141 
142  mutable Mutex myMutex;
144  };
145 
146  template <typename FS>
148  : virtual public FS
149 #ifdef DtObjectDebugger_Enable
150  , public DtObjectDebugger< DtPagingFeatureSetSubset<FS> >
151 #endif
152  {
153  public:
158 
160 
161  const Config& config() const { return *myInfo; }
162  const FS& input() const { return *config().inputFeatureSet; }
163  DtProj::Bounds bounds() const { return myBounds; }
165  SubsetPtr parent() const { return myParent; }
166  int level() const { return myLevel; }
167 
168  virtual FS* filterCache(
169  const DtQuery&,
170  const boost::optional<DtFeatureGeometry>&,
171  DtLoadType,
172  SubsetCPtr& highestSubset,
173  const DtProj::Bounds::LineSegment* = 0,
174  unsigned indexLevel = 0) const = 0;
175 
176  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
177 
178  virtual boost::optional<unsigned> sizeEstimate() const = 0;
179  virtual void updateStats();
180 
181  protected:
182  DtPagingFeatureSetSubset(const GridCPtr& parent, unsigned i);
183  DtPagingFeatureSetSubset(const typename Config::Ptr&, const DtProj::Bounds&);
184 
185  const typename Config::Ptr myInfo;
186  const int myLevel;
187 
189 
192  };
193 
194  template <typename FS>
195  template <template <class> class PtrT>
197  : public DtPagingFeatureSet<FS>::Subset
198  {
199  public:
200  struct Tile
201  {
202  explicit Tile(const DtProj::Bounds& b, unsigned i);
203 
206 
208  };
209 
210  typedef typename FS::DetachCallback DetachCallback;
211  typedef typename FS::LoadedCallback LoadedCallback;
212 
213  std::string label() const;
214 
215  void forEachFeatureParallel(const ForEachFunction&) const;
216  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
217 
218  boost::optional<unsigned> sizeEstimate() const;
219  void updateStats();
220 
221  const DtProj::Bounds& subBounds(unsigned) const;
222  const DtFeatureGeometry::Area& subGeometry(unsigned) const;
223 
224  Tile& getSubtile(unsigned);
225  const Tile& getSubtile(unsigned) const;
226 
227  bool loaded(double) const;
228  DetachCallback addLoadedCallback(const LoadedCallback&) const;
229  unsigned numberOfFeatures() const;
230  bool elided() const;
231  bool empty() const;
232 
233  GridTemplate(const typename Config::Ptr& cfg, const DtProj::Bounds&);
234 
235  protected:
236  struct Detacher;
237 
238  GridTemplate(const GridCPtr& parent, unsigned i);
239 
240  typedef tbb::spin_rw_mutex SizeMutex;
242 
247 
248  boost::optional<unsigned> mySizeEstimate;
249  const bool myEmptyFlag;
250  };
251 
252  template <typename FS>
254  : public DtPagingFeatureSet<FS>::template GridTemplate<boost::weak_ptr>
255  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
256 #ifdef DtObjectDebugger_Enable
257  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Grid>
258 #endif
259  {
260  public:
261  FS* filterCache(
262  const DtQuery&,
263  const boost::optional<DtFeatureGeometry>&,
264  DtLoadType,
265  SubsetCPtr& highestSubset,
267  unsigned indexLevel) const;
268 
269  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
270 
271  void cacheData(
272  const boost::optional<DtFeatureGeometry>& area,
273  DtFeatureCacheProgressCallback* progress) const;
274 
275  FS* clone() const;
276 
277  Grid(const typename Config::Ptr& cfg, const DtProj::Bounds&);
278 
279  protected:
280  virtual bool makeLeaf(unsigned) const;
281 
282  Grid(const GridCPtr& parent, unsigned i);
283  };
284 
285  template <typename FS>
287  : public DtPagingFeatureSet<FS>::Subset
288  , public DtQueueLoadingFeatureSet<FS>
289 #ifdef DtObjectDebugger_Enable
290  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Leaf>
291 #endif
292  {
293  public:
294  typedef typename FS::ForEachFunction ForEachFunction;
295  typedef typename FS::DetachCallback DetachCallback;
296 
297  typedef std::vector<typename Feature::CPtr> FeatureVector;
298 
299  ~Leaf();
300 
301  bool loaded(double = 0) const;
302  unsigned numberOfFeatures() const;
303  bool elided() const;
304  void forEachFeatureParallel(const ForEachFunction&) const;
305  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
306 
307  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
308 
309  FS* filterCache(
310  const DtQuery&,
311  const boost::optional<DtFeatureGeometry>&,
312  DtLoadType,
313  SubsetCPtr& highestSubset,
315  unsigned indexLevel) const;
316 
317  boost::optional<unsigned> sizeEstimate() const;
318 
319  FS* clone() const;
320 
321  std::string label() const;
322 
323  Leaf(const GridCPtr& parent, unsigned i);
324 
325  LeafPtr shared_from_this();
326  LeafCPtr shared_from_this() const;
327 
328  bool unload();
329 
330  protected:
331  void makeTileFeature(const DtFeatureGeometry& geom, unsigned color);
332 
333  void start(bool wait);
334  bool run(bool wait);
335  FS* createFeatureSet(FS*) const;
336  void inputLoadedCallback();
337 
338  typedef tbb::spin_mutex TileFeatureMutex;
340  std::auto_ptr<DtTileFeature> myTileFeature;
341  };
342 }
343 
DtPagingFeatureSet< FS >::SubsetPtr SubsetPtr
Definition: pagingFeatureSet.h:154
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
boost::shared_ptr< const Grid > GridCPtr
Definition: pagingFeatureSet.h:69
virtual boost::optional< unsigned > sizeEstimate() const =0
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:44
FeatureSet::Feature Feature
Definition: pagingFeatureSet.h:62
Class DtTerrainInterfaceConfig is a readable-writable class holding terrain interface configuration o...
Definition: terrainInterfaceConfig.h:32
boost::shared_ptr< const Leaf > LeafCPtr
Definition: pagingFeatureSet.h:71
boost::shared_ptr< Leaf > LeafPtr
Definition: pagingFeatureSet.h:70
tbb::spin_rw_mutex SizeMutex
Definition: pagingFeatureSet.h:240
FS::ForEachFunction ForEachFunction
Definition: pagingFeatureSet.h:294
boost::shared_ptr< Config > Ptr
Definition: pagingFeatureSet.h:78
boost::shared_ptr< const Subset > SubsetCPtr
Definition: pagingFeatureSet.h:67
boost::weak_ptr< DtUnusedFeatureTileTracker > WeakPtr
Definition: unusedFeatureTileTracker.h:53
Definition: asyncLoadingFeatureSet.h:163
Definition: pagingFeatureSet.h:196
FS * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
const Config & config() const
Definition: pagingFeatureSet.h:161
FS FeatureSet
Definition: pagingFeatureSet.h:61
const bool myEmptyFlag
Definition: pagingFeatureSet.h:249
tbb::spin_mutex TileFeatureMutex
Definition: pagingFeatureSet.h:338
boost::optional< unsigned > mySizeEstimate
Definition: pagingFeatureSet.h:248
voidpf void uLong size
Definition: ioapi.h:39
void cacheEstimate(double &time, double &size, const boost::optional< DtFeatureGeometry > &area) const
Tile mySubtile3
Definition: pagingFeatureSet.h:246
TileFeatureMutex myTileFeatureMutex
Definition: pagingFeatureSet.h:339
const DtProj::Bounds myBounds
Definition: pagingFeatureSet.h:190
const DtProj::Bounds bounds
Definition: pagingFeatureSet.h:204
std::auto_ptr< DtTileFeature > myTileFeature
Definition: pagingFeatureSet.h:340
Default on in debug, off in release.
Definition: objectCounter.h:27
DtUnusedFeatureTileTracker::WeakPtr unusedTileTracker
Unused tile tracker which will manage the feature sets. This can be null and feature sets will be des...
Definition: pagingFeatureSet.h:87
DtPagingFeatureSet< FS >::GridCPtr GridCPtr
Definition: pagingFeatureSet.h:157
const SubsetPtr myParent
Definition: pagingFeatureSet.h:188
Definition: featureGeometry.h:60
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
Definition: proj.h:68
Definition: featureSet.h:60
FeatureSet::ForEachFunction ForEachFunction
Definition: pagingFeatureSet.h:63
FS * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
FS::DetachCallback DetachCallback
Definition: pagingFeatureSet.h:295
Tile mySubtile1
Definition: pagingFeatureSet.h:244
DtPagingFeatureSetSubset(const GridCPtr &parent, unsigned i)
DtPagingFeatureSet< FS >::Config Config
Definition: pagingFeatureSet.h:159
DtPagingFeatureSet< FS >::Grid Grid
Definition: pagingFeatureSet.h:156
virtual FS * filterCache(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType, SubsetCPtr &highestSubset, const DtProj::Bounds::LineSegment *=0, unsigned indexLevel=0) const =0
SizeMutex mySizeMutex
Definition: pagingFeatureSet.h:241
Definition: pagingFeatureSet.h:253
tbb::spin_mutex Mutex
Definition: pagingFeatureSet.h:140
static DtPagingFeatureSet * Make(Config *cfg, const DtProj::Bounds &bounds)
Factory functions for creating a pagetables.
Definition: pagingFeatureSet.h:112
Tile mySubtile2
Definition: pagingFeatureSet.h:245
DtPagingFeatureSetSubset< FS > Subset
Definition: pagingFeatureSet.h:56
int level() const
Definition: pagingFeatureSet.h:166
std::vector< typename Feature::CPtr > FeatureVector
Definition: pagingFeatureSet.h:297
Represents a set of characeters a DtFeature object can have. DtQuery objects are the way to communica...
Definition: query.h:38
FS::LoadedCallback LoadedCallback
Definition: pagingFeatureSet.h:211
Configuration object. Create an instance and change as desired.
Definition: pagingFeatureSet.h:75
Features pagetable class. This class is just the shell around a set of related classes. The general idea is a hierarchy of subsets/tiles from an arbitrary 2D coordsys. It uses weak pointers to manage its contained feature sets while returning feature sets which have shared pointers. This way feature sets will automatically be destroyed when users are done with them. The unused tile tracker can provide an owner for these feature sets and pages them out according to it&#39;s own policy.
Definition: featuresDebugger.h:31
SubsetPtr parent() const
Definition: pagingFeatureSet.h:165
DtPagingFeatureSet< FS >::SubsetCPtr SubsetCPtr
Definition: pagingFeatureSet.h:155
FeatureSet::DetachCallback DetachCallback
Definition: asyncLoadingFeatureSet.h:46
void cacheData(const boost::optional< DtFeatureGeometry > &area, DtFeatureCacheProgressCallback *progress) const
SubsetCPtr myTile
Definition: pagingFeatureSet.h:143
#define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type)
Definition: objectCounter.h:32
DtQueueLoadingFeatureSet< FeatureSet >::Queue Queue
Definition: pagingFeatureSet.h:79
Tile mySubtile0
Definition: pagingFeatureSet.h:243
FS::DetachCallback DetachCallback
Definition: pagingFeatureSet.h:210
class DT_DLL_features Grid
Definition: pagingFeatureSet.h:57
boost::shared_ptr< DtFeatureSet::Source > tileFeatures
Feature set used to represent tile boundaries This is only used for debug drawing currently...
Definition: pagingFeatureSet.h:94
boost::shared_ptr< Grid > GridPtr
Definition: pagingFeatureSet.h:68
const Config::Ptr myInfo
Definition: pagingFeatureSet.h:185
boost::shared_ptr< DtPagingFeatureSet > Ptr
Definition: pagingFeatureSet.h:65
DtFeatureSetWrapper< FS, boost::shared_ptr, DtPagingFeatureSetSubset< FS > > Base
Definition: pagingFeatureSet.h:51
DtFeatureSetWrapper< FS, PtrT, Subset > subtile
Definition: pagingFeatureSet.h:207
DtPagingFeatureSet * clone() const
const DtFeatureGeometry::Area myTileGeometry
Definition: pagingFeatureSet.h:191
DtLoadType
Used to indicate whether to load features. See DtFeatureSetTemplate::filter.
Definition: featureSet.h:36
class DT_DLL_features Leaf
Definition: pagingFeatureSet.h:59
const FS & input() const
Definition: pagingFeatureSet.h:162
static DtPagingFeatureSet * Make(const Config &cfg, const DtProj::Bounds &bounds)
Factory functions for creating a pagetables.
Definition: pagingFeatureSet.h:119
DtFeatureGeometry::Area tileGeometry() const
Definition: pagingFeatureSet.h:164
class DT_DLL_features GridTemplate
Definition: pagingFeatureSet.h:55
boost::weak_ptr< Queue > taskQueue
Task queue used for loading tiles.
Definition: pagingFeatureSet.h:90
Definition: pagingFeatureSet.h:147
boost::shared_ptr< FeatureSet > inputFeatureSet
Feature set the pagetable will read from.
Definition: pagingFeatureSet.h:82
boost::shared_ptr< Subset > SubsetPtr
Definition: pagingFeatureSet.h:66
const DtFeatureGeometry::Area tileGeometry
Definition: pagingFeatureSet.h:205
const int myLevel
Definition: pagingFeatureSet.h:186
Mutex myMutex
Definition: pagingFeatureSet.h:142
Config(const Config &cfg)
Copy constructor.
Definition: pagingFeatureSet.h:100
Represents a feature geometry.
Definition: featureGeometry.h:39
Definition: pagingFeatureSet.h:286
DtProj::Bounds bounds() const
Definition: pagingFeatureSet.h:163

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)