VR-Forces 5.0.1 Developer's Guide
 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) 2020 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>
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 #ifdef DtObjectDebugger_Enable
104  , public DtObjectDebugger< DtFeatureSetTemplate<F> >
105 #endif
106  {
107  public:
109  typedef F Feature;
110 
113 
125  typedef boost::function<void ()> DetachCallback;
126 
128  class DetachScopeGuard : boost::noncopyable
129  {
131 
132  public:
134  callback(cb) {};
136  {
137  if (callback)
138  {
139  callback();
140  }
141  };
142 
143  void reset(const DetachCallback& cb = DetachCallback())
144  {
145  if (callback)
146  callback();
147 
148  callback = cb;
149  };
150  };
151 
153  typedef boost::function<void (const Feature&)> ForEachFunction;
154 
156  typedef boost::function<void ()> LoadedCallback;
157 
160 
163 
165 
172 
185  template <typename FS>
186  static FeatureSet* Wrap(FS* fs)
187  {
188  std::auto_ptr<FS> set(fs);
189  return Wrap(set);
190  }
191 
193  {
194  return fs;
195  }
196 
197  static DtFeatureSetTemplate* Wrap(std::auto_ptr<FeatureSet> fs)
198  {
199  return fs.release();
200  }
201 
202  template <typename FS>
203  static FeatureSet* Wrap(std::auto_ptr<FS> fs)
204  {
205  if (!fs.get() || fs->elided())
206  return 0;
207 
209  }
210 
211  template <typename FS>
212  static FeatureSet* Wrap(const boost::shared_ptr<FS>& fs)
213  {
214  if (!fs || fs->elided())
215  return 0;
216 
218  }
219 
220  template <typename FS>
221  static FeatureSet* Wrap(const boost::weak_ptr<FS>& fs)
222  {
223  boost::shared_ptr<FS> ptr(fs.lock());
224  if (!ptr || ptr->elided())
225  return 0;
226 
228  }
230 
232  virtual ~DtFeatureSetTemplate();
233 
237  virtual std::string label() const = 0;
238 
246  virtual void forEachFeatureParallel(const ForEachFunction& func) const = 0;
247 
249  void forEachFeature(const ForEachFunction& func) const;
250 
253 
254  bool forEachFeatureParallelBlock(const ForEachFunction& func, double timeout = 60) const;
255  bool forEachFeatureBlock(const ForEachFunction& func, double timeout = 60) const;
257 
282  virtual DetachCallback forEachFeatureAsync(const ForEachFunction& func) const = 0;
284 
295 
296  virtual DtFeatureSetTemplate* filter(
297  const DtQuery& query,
298  const boost::optional<DtFeatureGeometry>& geometry,
299  DtLoadType load) const;
300 
301  DtFeatureSetTemplate* filter(
302  const DtQuery& query, DtLoadType load) const;
303 
304  DtFeatureSetTemplate* filter(
305  const boost::optional<DtFeatureGeometry>& geometry, DtLoadType load) const;
307 
314 
315  virtual bool load(
316  const DtQuery& query,
317  const boost::optional<DtFeatureGeometry>& geometry) const;
318 
319  bool load(const DtQuery& query) const;
320  bool load(const boost::optional<DtFeatureGeometry>& geometry) const;
322 
329  virtual DtFeatureSetTemplate* clone() const = 0;
330 
348  virtual bool loaded(double timeout=0.0) const = 0;
349 
359  virtual DetachCallback addLoadedCallback(const LoadedCallback&) const = 0;
360 
370  virtual bool elided() const = 0;
371 
379  virtual bool empty() const = 0;
380 
383  virtual bool isIndexed() const;
384 
388  virtual bool isCacheable(const boost::optional<DtFeatureGeometry>& area = boost::none_t()) const;
389 
393  virtual void cacheEstimate(
394  double& time, double& size,
395  const boost::optional<DtFeatureGeometry>& area = boost::none_t()) const;
396 
399  virtual void cacheData(
400  const boost::optional<DtFeatureGeometry>& area = boost::none_t(),
401  DtFeatureCacheProgressCallback* progress = 0) const;
403 
418  virtual unsigned numberOfFeatures() const;
419 
424 
426  {
427  public:
428  virtual ~Visitor();
429  virtual void visit(FeatureSet&) = 0;
430  };
431 
433  {
434  public:
435  virtual ~ConstVisitor();
436  virtual void visit(const FeatureSet&) = 0;
437  };
439 
444 
445  virtual void accept(Visitor&);
446  virtual void accept(ConstVisitor&) const;
448 
449  protected:
450  class SynchronizedFunction;
451  struct FeatureCounter;
452  };
453 
455  template <typename F>
457  {
458  return from.clone();
459  }
460 
463 
464  template <typename FS>
465  inline bool DtIsElided(const FS& fs)
466  {
467  return fs.elided();
468  }
469 
470  template <typename FS>
471  inline bool DtIsElided(FS* fs)
472  {
473  if (!fs)
474  return true;
475 
476  return DtIsElided(*fs);
477  }
479 
481 }
482 
484 #define DT_INSTANTIATE_FEATURE_SETS(F) \
485  template class MAKVRinTerra::DtFeatureSetTemplate<F>; \
486  template class MAKVRinTerra::DtFeatureSetList< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
487  template class MAKVRinTerra::DtFeatureSetArray<4, MAKVRinTerra::DtFeatureSetTemplate<F> >; \
488  template class MAKVRinTerra::DtFilteredFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
489  template class MAKVRinTerra::DtEmptyFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
490  template class MAKVRinTerra::DtSinkFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
491  template class MAKVRinTerra::DtSourceFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
492  template class MAKVRinTerra::DtAsyncLoadingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
493  template class MAKVRinTerra::DtPagingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
494 
Represents a set of DtFeature objects or others which conform to the DtFeature concept.
Definition: featureSet.h:101
DtFeatureSet which filters out features from a feature set. Wraps a feature set with a geometry and q...
Definition: featureSetUtils.h:48
boost::function< void(const Feature &)> ForEachFunction
Callback type type for iterating through features.
Definition: featureSet.h:153
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
virtual DtFeatureSetTemplate * clone() const =0
Clone the feature set. Called assumes ownership of returned feature set. Implementation should share ...
void reset(const DetachCallback &cb=DetachCallback())
Definition: featureSet.h:143
DtFilteredFeatureSet< FeatureSet > Filtered
Typedefs for various features system framework classes.
Definition: featureSet.h:167
Definition: featureSetList.h:98
static FeatureSet * Wrap(FS *fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:186
boost::function< void()> DetachCallback
Callback type for disconnecting other callbacks. Functions which register callbacks return a DetachCa...
Definition: featureSet.h:125
Load all features which may be in the feature set.
Definition: featureSet.h:39
voidpf void uLong size
Definition: ioapi.h:39
Do not initiate new loads, read whatever is currently loaded.
Definition: featureSet.h:45
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
DtSourceFeatureSet< FeatureSet > Source
Typedefs for various features system framework classes.
Definition: featureSet.h:170
Default on in debug, off in release.
Definition: objectCounter.h:31
F Feature
Type of feature objects accessed through this interface.
Definition: featureSet.h:109
static DtFeatureSetTemplate * Wrap(std::auto_ptr< FeatureSet > fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:197
Definition: featureSet.h:60
DtEmptyFeatureSet< FeatureSet > Empty
Typedefs for various features system framework classes.
Definition: featureSet.h:168
DtFeatureSetTemplate FeatureSet
Feature set type.
Definition: featureSet.h:112
DtFeatureSetWrapper< FeatureSet, boost::shared_ptr > SharedWrapper
Wraps a boost::shared_ptr to a feature set.
Definition: featureSet.h:162
static FeatureSet * Wrap(const boost::weak_ptr< FS > &fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:221
DtFeatureSetList< FeatureSet > List
Typedefs for various features system framework classes.
Definition: featureSet.h:166
Load all features but try to do as little work in the calling thread as possible. Not all feature set...
Definition: featureSet.h:43
DtFeatureSetTemplate< F > * new_clone(const DtFeatureSetTemplate< F > &from)
Makes DtFeatureSetTemplate usable with boost pointer containers.
Definition: featureSet.h:456
Definition: feature.h:26
Feature set object which will take another feature set, iterate over its contents asynchronously and ...
Definition: featureSetUtils.h:144
DetachScopeGuard(const DetachCallback &cb=DetachCallback())
Definition: featureSet.h:133
Represents a set of characeters a DtFeature object can have. DtQuery objects are the way to communica...
Definition: query.h:38
#define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type)
Definition: objectCounter.h:275
Dummy feature set which contains no features.
Definition: featureSetUtils.h:103
bool DtIsElided(const FS &fs)
Helper functions using null pointers to feature sets to denote empty feature sets. This helps avoid dynamically allocating lots of empty feature sets.
Definition: featureSet.h:465
DtLoadType
Used to indicate whether to load features. See DtFeatureSetTemplate::filter.
Definition: featureSet.h:36
DtFeatureSetTemplate< DtFeature > DtFeatureSet
Definition: featureSet.h:480
DetachCallback callback
Definition: featureSet.h:130
Source feature sets are used to create your own feature sets with your own features.
Definition: featureSetUtils.h:286
DtFeatureSetWrapper< FeatureSet, boost::scoped_ptr > ScopedWrapper
Wraps a boost::scoped_ptr to a feature set.
Definition: featureSet.h:159
Scope guard which will automatically call detach callback in destructor.
Definition: featureSet.h:128
DtFeatureSet used to combine multiple feature sets into one. This class allows all feature set algori...
Definition: featureSetList.h:26
boost::function< void()> LoadedCallback
Callback type type for async notification of feature set loading.
Definition: featureSet.h:156
static FeatureSet * Wrap(std::auto_ptr< FS > fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:203
static FeatureSet * Wrap(const boost::shared_ptr< FS > &fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:212
static DtFeatureSetTemplate * Wrap(DtFeatureSetTemplate *fs)
Wrap a compatible feature set type in the interface of this feature set type. The Wrap functions are ...
Definition: featureSet.h:192
DtSinkFeatureSet< FeatureSet > Sink
Typedefs for various features system framework classes.
Definition: featureSet.h:169
Visitors allow feature sets which are implemented as compound structures of other feature sets to exp...
Definition: featureSet.h:425

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)