VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pagingFeatureSet.h
Go to the documentation of this file.
1 
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:
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  bool isCacheable(const boost::optional<DtFeatureGeometry>& area) const;
123  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
124 
125  void cacheData(
126  const boost::optional<DtFeatureGeometry>& area,
127  DtFeatureCacheProgressCallback* progress) const;
128 
129  protected:
130  explicit DtPagingFeatureSet(const SubsetCPtr&);
131  explicit DtPagingFeatureSet(const DtPagingFeatureSet&);
132 
133  typedef tbb::spin_mutex Mutex;
134 
135  mutable Mutex myMutex;
137  };
138 
139  template <typename FS>
141  : virtual public FS
142  , public DtObjectDebugger< DtPagingFeatureSetSubset<FS> >
143  {
144  public:
149 
151 
152  const Config& config() const { return *myInfo; }
153  const FS& input() const { return *config().inputFeatureSet; }
154  DtProj::Bounds bounds() const { return myBounds; }
156  SubsetPtr parent() const { return myParent; }
157  int level() const { return myLevel; }
158 
159  virtual FS* filterCache(
160  const DtQuery&,
161  const boost::optional<DtFeatureGeometry>&,
162  DtLoadType,
163  SubsetCPtr& highestSubset,
164  const DtProj::Bounds::LineSegment* = 0,
165  unsigned indexLevel = 0) const = 0;
166 
167  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
168 
169  virtual boost::optional<unsigned> sizeEstimate() const = 0;
170  virtual void updateStats();
171 
172  protected:
173  DtPagingFeatureSetSubset(const GridCPtr& parent, unsigned i);
174  DtPagingFeatureSetSubset(const typename Config::Ptr&, const DtProj::Bounds&);
175 
176  const typename Config::Ptr myInfo;
177  const int myLevel;
178 
180 
183  };
184 
185  template <typename FS>
186  template <template <class> class PtrT>
188  : public DtPagingFeatureSet<FS>::Subset
189  {
190  public:
191  struct Tile
192  {
193  explicit Tile(const DtProj::Bounds& b, unsigned i);
194 
197 
199  };
200 
201  typedef typename FS::DetachCallback DetachCallback;
202  typedef typename FS::LoadedCallback LoadedCallback;
203 
204  std::string label() const;
205 
206  void forEachFeatureParallel(const ForEachFunction&) const;
207  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
208 
209  boost::optional<unsigned> sizeEstimate() const;
210  void updateStats();
211 
212  const DtProj::Bounds& subBounds(unsigned) const;
213  const DtFeatureGeometry::Area& subGeometry(unsigned) const;
214 
215  Tile& getSubtile(unsigned);
216  const Tile& getSubtile(unsigned) const;
217 
218  bool loaded(double) const;
219  DetachCallback addLoadedCallback(const LoadedCallback&) const;
220  unsigned numberOfFeatures() const;
221  bool elided() const;
222  bool empty() const;
223 
224  GridTemplate(const typename Config::Ptr& cfg, const DtProj::Bounds&);
225 
226  protected:
227  struct Detacher;
228 
229  GridTemplate(const GridCPtr& parent, unsigned i);
230 
231  typedef tbb::spin_rw_mutex SizeMutex;
233 
238 
239  boost::optional<unsigned> mySizeEstimate;
240  const bool myEmptyFlag;
241  };
242 
243  template <typename FS>
245  : public DtPagingFeatureSet<FS>::template GridTemplate<boost::weak_ptr>
246  , public boost::enable_shared_from_this<typename DtPagingFeatureSet<FS>::Grid>
247  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Grid>
248  {
249  public:
250  FS* filterCache(
251  const DtQuery&,
252  const boost::optional<DtFeatureGeometry>&,
253  DtLoadType,
254  SubsetCPtr& highestSubset,
256  unsigned indexLevel) const;
257 
258  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
259 
260  void cacheData(
261  const boost::optional<DtFeatureGeometry>& area,
262  DtFeatureCacheProgressCallback* progress) const;
263 
264  FS* clone() const;
265 
266  Grid(const typename Config::Ptr& cfg, const DtProj::Bounds&);
267 
268  protected:
269  virtual bool makeLeaf(unsigned) const;
270 
271  Grid(const GridCPtr& parent, unsigned i);
272  };
273 
274  template <typename FS>
276  : public DtPagingFeatureSet<FS>::Subset
277  , public DtQueueLoadingFeatureSet<FS>
278  , public DtObjectDebugger<typename DtPagingFeatureSet<FS>::Leaf>
279  {
280  public:
281  typedef typename FS::ForEachFunction ForEachFunction;
282  typedef typename FS::DetachCallback DetachCallback;
283 
284  typedef std::vector<typename Feature::CPtr> FeatureVector;
285 
286  ~Leaf();
287 
288  bool loaded(double = 0) const;
289  unsigned numberOfFeatures() const;
290  bool elided() const;
291  void forEachFeatureParallel(const ForEachFunction&) const;
292  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
293 
294  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
295 
296  FS* filterCache(
297  const DtQuery&,
298  const boost::optional<DtFeatureGeometry>&,
299  DtLoadType,
300  SubsetCPtr& highestSubset,
302  unsigned indexLevel) const;
303 
304  boost::optional<unsigned> sizeEstimate() const;
305 
306  FS* clone() const;
307 
308  std::string label() const;
309 
310  Leaf(const GridCPtr& parent, unsigned i);
311 
312  LeafPtr shared_from_this();
313  LeafCPtr shared_from_this() const;
314 
315  bool unload();
316 
317  protected:
318  void makeTileFeature(const DtFeatureGeometry& geom, unsigned color);
319 
320  void start(bool wait);
321  bool run(bool wait);
322  FS* createFeatureSet(FS*) const;
323  void inputLoadedCallback();
324 
325  typedef tbb::spin_mutex TileFeatureMutex;
327  std::auto_ptr<DtTileFeature> myTileFeature;
328  };
329 }
330 
DtPagingFeatureSet< FS >::SubsetPtr SubsetPtr
Definition: pagingFeatureSet.h:145
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:36
boost::shared_ptr< const Grid > GridCPtr
Definition: pagingFeatureSet.h:62
virtual boost::optional< unsigned > sizeEstimate() const =0
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:44
FeatureSet::Feature Feature
Definition: pagingFeatureSet.h:55
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:64
boost::shared_ptr< Leaf > LeafPtr
Definition: pagingFeatureSet.h:63
tbb::spin_rw_mutex SizeMutex
Definition: pagingFeatureSet.h:231
FS::ForEachFunction ForEachFunction
Definition: pagingFeatureSet.h:281
boost::shared_ptr< Config > Ptr
Definition: pagingFeatureSet.h:71
boost::shared_ptr< const Subset > SubsetCPtr
Definition: pagingFeatureSet.h:60
boost::weak_ptr< DtUnusedFeatureTileTracker > WeakPtr
Definition: unusedFeatureTileTracker.h:51
Definition: asyncLoadingFeatureSet.h:161
Definition: pagingFeatureSet.h:187
FS * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
const Config & config() const
Definition: pagingFeatureSet.h:152
FS FeatureSet
Definition: pagingFeatureSet.h:54
const bool myEmptyFlag
Definition: pagingFeatureSet.h:240
tbb::spin_mutex TileFeatureMutex
Definition: pagingFeatureSet.h:325
boost::optional< unsigned > mySizeEstimate
Definition: pagingFeatureSet.h:239
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:237
TileFeatureMutex myTileFeatureMutex
Definition: pagingFeatureSet.h:326
const DtProj::Bounds myBounds
Definition: pagingFeatureSet.h:181
const DtProj::Bounds bounds
Definition: pagingFeatureSet.h:195
std::auto_ptr< DtTileFeature > myTileFeature
Definition: pagingFeatureSet.h:327
Default on in debug, off in release.
Definition: objectCounter.h:31
DtUnusedFeatureTileTracker::WeakPtr unusedTileTracker
Unused tile tracker which will manage the feature sets.
Definition: pagingFeatureSet.h:80
DtPagingFeatureSet< FS >::GridCPtr GridCPtr
Definition: pagingFeatureSet.h:148
const SubsetPtr myParent
Definition: pagingFeatureSet.h:179
Definition: featureGeometry.h:54
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
Definition: proj.h:68
Definition: featureSet.h:60
FeatureSet::ForEachFunction ForEachFunction
Definition: pagingFeatureSet.h:56
FS * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
FS::DetachCallback DetachCallback
Definition: pagingFeatureSet.h:282
Tile mySubtile1
Definition: pagingFeatureSet.h:235
DtPagingFeatureSetSubset(const GridCPtr &parent, unsigned i)
DtPagingFeatureSet< FS >::Config Config
Definition: pagingFeatureSet.h:150
DtPagingFeatureSet< FS >::Grid Grid
Definition: pagingFeatureSet.h:147
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:232
Definition: pagingFeatureSet.h:244
tbb::spin_mutex Mutex
Definition: pagingFeatureSet.h:133
static DtPagingFeatureSet * Make(Config *cfg, const DtProj::Bounds &bounds)
Factory functions for creating a pagetables.
Definition: pagingFeatureSet.h:105
Tile mySubtile2
Definition: pagingFeatureSet.h:236
DtPagingFeatureSetSubset< FS > Subset
Definition: pagingFeatureSet.h:49
int level() const
Definition: pagingFeatureSet.h:157
std::vector< typename Feature::CPtr > FeatureVector
Definition: pagingFeatureSet.h:284
Represents a set of characeters a DtFeature object can have.
Definition: query.h:38
FS::LoadedCallback LoadedCallback
Definition: pagingFeatureSet.h:202
Configuration object.
Definition: pagingFeatureSet.h:68
Features pagetable class.
Definition: featuresDebugger.h:31
SubsetPtr parent() const
Definition: pagingFeatureSet.h:156
DtPagingFeatureSet< FS >::SubsetCPtr SubsetCPtr
Definition: pagingFeatureSet.h:146
FeatureSet::DetachCallback DetachCallback
Definition: asyncLoadingFeatureSet.h:46
void cacheData(const boost::optional< DtFeatureGeometry > &area, DtFeatureCacheProgressCallback *progress) const
SubsetCPtr myTile
Definition: pagingFeatureSet.h:136
#define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type)
Definition: objectCounter.h:275
DtQueueLoadingFeatureSet< FeatureSet >::Queue Queue
Definition: pagingFeatureSet.h:72
Tile mySubtile0
Definition: pagingFeatureSet.h:234
FS::DetachCallback DetachCallback
Definition: pagingFeatureSet.h:201
class DT_DLL_features Grid
Definition: pagingFeatureSet.h:50
boost::shared_ptr< DtFeatureSet::Source > tileFeatures
Feature set used to represent tile boundaries This is only used for debug drawing currently...
Definition: pagingFeatureSet.h:87
boost::shared_ptr< Grid > GridPtr
Definition: pagingFeatureSet.h:61
const Config::Ptr myInfo
Definition: pagingFeatureSet.h:176
boost::shared_ptr< DtPagingFeatureSet > Ptr
Definition: pagingFeatureSet.h:58
DtFeatureSetWrapper< FS, boost::shared_ptr, DtPagingFeatureSetSubset< FS > > Base
Definition: pagingFeatureSet.h:44
DtFeatureSetWrapper< FS, PtrT, Subset > subtile
Definition: pagingFeatureSet.h:198
DtPagingFeatureSet * clone() const
const DtFeatureGeometry::Area myTileGeometry
Definition: pagingFeatureSet.h:182
DtLoadType
Used to indicate whether to load features.
Definition: featureSet.h:36
class DT_DLL_features Leaf
Definition: pagingFeatureSet.h:52
const FS & input() const
Definition: pagingFeatureSet.h:153
static DtPagingFeatureSet * Make(const Config &cfg, const DtProj::Bounds &bounds)
Definition: pagingFeatureSet.h:112
DtFeatureGeometry::Area tileGeometry() const
Definition: pagingFeatureSet.h:155
class DT_DLL_features GridTemplate
Definition: pagingFeatureSet.h:48
boost::weak_ptr< Queue > taskQueue
Task queue used for loading tiles.
Definition: pagingFeatureSet.h:83
Definition: pagingFeatureSet.h:140
boost::shared_ptr< FeatureSet > inputFeatureSet
Feature set the pagetable will read from.
Definition: pagingFeatureSet.h:75
boost::shared_ptr< Subset > SubsetPtr
Definition: pagingFeatureSet.h:59
const DtFeatureGeometry::Area tileGeometry
Definition: pagingFeatureSet.h:196
const int myLevel
Definition: pagingFeatureSet.h:177
Mutex myMutex
Definition: pagingFeatureSet.h:135
Config(const Config &cfg)
Copy constructor.
Definition: pagingFeatureSet.h:93
Represents a feature geometry.
Definition: featureGeometry.h:35
Definition: pagingFeatureSet.h:275
DtProj::Bounds bounds() const
Definition: pagingFeatureSet.h:154

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)