VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
featureSet.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2014 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <memory>
15 #include <string>
16 
17 #include <boost/function.hpp>
18 #include <boost/scoped_ptr.hpp>
19 #include <boost/shared_ptr.hpp>
20 #include <boost/weak_ptr.hpp>
21 
22 #include <boost/optional.hpp>
23 #include <boost/noncopyable.hpp>
24 
25 #include <vrfutil/objectCounter.h>
27 
28 namespace MAKVRinTerra
29 {
30  class DtFeature;
31  class DtQuery;
32  class DtFeatureGeometry;
33 
37  {
46  };
47 
49  {
50  public:
51  virtual void layerName(const std::string&) = 0;
52  virtual void percent(double) = 0;
53  virtual bool isCancelled() = 0;
54  };
55 
56  template <
57  typename FS,
58  template <typename> class PtrTemplate = boost::scoped_ptr,
59  typename InnerFS = FS>
60  class DtFeatureSetWrapper;
61 
63  {
64  public:
66  };
67 
68  template <typename FS, typename InnerFS = FS>
70 
71  template <size_t N, typename FS, typename InnerFS = FS>
73 
74  template <typename FS>
76 
77  template <typename FS>
79 
80  template <typename FS, typename F = typename FS::Feature>
82 
83  template <typename FS>
85 
100  template <typename F>
102  : private boost::noncopyable
103  , public DtObjectDebugger< DtFeatureSetTemplate<F> >
104  {
105  public:
107  typedef F Feature;
108 
111 
123  typedef boost::function<void ()> DetachCallback;
124 
126  class DetachScopeGuard : boost::noncopyable
127  {
129 
130  public:
132  callback(cb) {};
134  {
135  if (callback)
136  {
137  callback();
138  }
139  };
140 
141  void reset(const DetachCallback& cb = DetachCallback())
142  {
143  if (callback)
144  callback();
145 
146  callback = cb;
147  };
148  };
149 
151  typedef boost::function<void (const Feature&)> ForEachFunction;
152 
154  typedef boost::function<void ()> LoadedCallback;
155 
158 
161 
163 
170 
183  template <typename FS>
184  static FeatureSet* Wrap(FS* fs)
185  {
186  std::auto_ptr<FS> set(fs);
187  return Wrap(set);
188  }
189 
191  {
192  return fs;
193  }
194 
195  static DtFeatureSetTemplate* Wrap(std::auto_ptr<FeatureSet> fs)
196  {
197  return fs.release();
198  }
199 
200  template <typename FS>
201  static FeatureSet* Wrap(std::auto_ptr<FS> fs)
202  {
203  if (!fs.get() || fs->elided())
204  return 0;
205 
207  }
208 
209  template <typename FS>
210  static FeatureSet* Wrap(const boost::shared_ptr<FS>& fs)
211  {
212  if (!fs || fs->elided())
213  return 0;
214 
216  }
217 
218  template <typename FS>
219  static FeatureSet* Wrap(const boost::weak_ptr<FS>& fs)
220  {
221  boost::shared_ptr<FS> ptr(fs.lock());
222  if (!ptr || ptr->elided())
223  return 0;
224 
226  }
228 
230  virtual ~DtFeatureSetTemplate();
231 
235  virtual std::string label() const = 0;
236 
244  virtual void forEachFeatureParallel(const ForEachFunction& func) const = 0;
245 
247  void forEachFeature(const ForEachFunction& func) const;
248 
251 
252  bool forEachFeatureParallelBlock(const ForEachFunction& func, double timeout = 60) const;
253  bool forEachFeatureBlock(const ForEachFunction& func, double timeout = 60) const;
255 
280  virtual DetachCallback forEachFeatureAsync(const ForEachFunction& func) const = 0;
282 
293 
294  virtual DtFeatureSetTemplate* filter(
295  const DtQuery& query,
296  const boost::optional<DtFeatureGeometry>& geometry,
297  DtLoadType load) const;
298 
299  DtFeatureSetTemplate* filter(
300  const DtQuery& query, DtLoadType load) const;
301 
302  DtFeatureSetTemplate* filter(
303  const boost::optional<DtFeatureGeometry>& geometry, DtLoadType load) const;
305 
312 
313  virtual bool load(
314  const DtQuery& query,
315  const boost::optional<DtFeatureGeometry>& geometry) const;
316 
317  bool load(const DtQuery& query) const;
318  bool load(const boost::optional<DtFeatureGeometry>& geometry) const;
320 
327  virtual DtFeatureSetTemplate* clone() const = 0;
328 
346  virtual bool loaded(double timeout=0.0) const = 0;
347 
357  virtual DetachCallback addLoadedCallback(const LoadedCallback&) const = 0;
358 
368  virtual bool elided() const = 0;
369 
377  virtual bool empty() const = 0;
378 
381  virtual bool isIndexed() const;
382 
386  virtual bool isCacheable(const boost::optional<DtFeatureGeometry>& area = boost::none_t()) const;
387 
391  virtual void cacheEstimate(
392  double& time, double& size,
393  const boost::optional<DtFeatureGeometry>& area = boost::none_t()) const;
394 
397  virtual void cacheData(
398  const boost::optional<DtFeatureGeometry>& area = boost::none_t(),
399  DtFeatureCacheProgressCallback* progress = 0) const;
401 
416  virtual unsigned numberOfFeatures() const;
417 
422 
424  {
425  public:
426  virtual ~Visitor();
427  virtual void visit(FeatureSet&) = 0;
428  };
429 
431  {
432  public:
433  virtual ~ConstVisitor();
434  virtual void visit(const FeatureSet&) = 0;
435  };
437 
442 
443  virtual void accept(Visitor&);
444  virtual void accept(ConstVisitor&) const;
446 
447  protected:
448  class SynchronizedFunction;
449  struct FeatureCounter;
450  };
451 
453  template <typename F>
455  {
456  return from.clone();
457  }
458 
461 
462  template <typename FS>
463  inline bool DtIsElided(const FS& fs)
464  {
465  return fs.elided();
466  }
467 
468  template <typename FS>
469  inline bool DtIsElided(FS* fs)
470  {
471  if (!fs)
472  return true;
473 
474  return DtIsElided(*fs);
475  }
477 
479 }
480 
482 #define DT_INSTANTIATE_FEATURE_SETS(F) \
483  template class MAKVRinTerra::DtFeatureSetTemplate<F>; \
484  template class MAKVRinTerra::DtFeatureSetList< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
485  template class MAKVRinTerra::DtFeatureSetArray<4, MAKVRinTerra::DtFeatureSetTemplate<F> >; \
486  template class MAKVRinTerra::DtFilteredFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
487  template class MAKVRinTerra::DtEmptyFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
488  template class MAKVRinTerra::DtSinkFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
489  template class MAKVRinTerra::DtSourceFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
490  template class MAKVRinTerra::DtAsyncLoadingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
491  template class MAKVRinTerra::DtPagingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
492 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)