VR-Forces 4.8 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>
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 
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.
Definition: featureSetUtils.h:48
boost::function< void(const Feature &)> ForEachFunction
Callback type type for iterating through features.
Definition: featureSet.h:151
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:36
virtual DtFeatureSetTemplate * clone() const =0
Clone the feature set.
void reset(const DetachCallback &cb=DetachCallback())
Definition: featureSet.h:141
DtFilteredFeatureSet< FeatureSet > Filtered
Definition: featureSet.h:165
Definition: featureSetList.h:91
static FeatureSet * Wrap(FS *fs)
Wrap a compatible feature set type in the interface of this feature set type.
Definition: featureSet.h:184
boost::function< void()> DetachCallback
Callback type for disconnecting other callbacks.
Definition: featureSet.h:123
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
Definition: featureSet.h:168
Default on in debug, off in release.
Definition: objectCounter.h:31
F Feature
Type of feature objects accessed through this interface.
Definition: featureSet.h:107
static DtFeatureSetTemplate * Wrap(std::auto_ptr< FeatureSet > fs)
Definition: featureSet.h:195
Definition: featureSet.h:60
DtEmptyFeatureSet< FeatureSet > Empty
Definition: featureSet.h:166
DtFeatureSetTemplate FeatureSet
Feature set type.
Definition: featureSet.h:110
DtFeatureSetWrapper< FeatureSet, boost::shared_ptr > SharedWrapper
Wraps a boost::shared_ptr to a feature set.
Definition: featureSet.h:160
static FeatureSet * Wrap(const boost::weak_ptr< FS > &fs)
Definition: featureSet.h:219
DtFeatureSetList< FeatureSet > List
Typedefs for various features system framework classes.
Definition: featureSet.h:164
Load all features but try to do as little work in the calling thread as possible. ...
Definition: featureSet.h:43
DtFeatureSetTemplate< F > * new_clone(const DtFeatureSetTemplate< F > &from)
Makes DtFeatureSetTemplate usable with boost pointer containers.
Definition: featureSet.h:454
Definition: feature.h:26
Feature set object which will take another feature set, iterate over its contents asynchronously and ...
Definition: featureSetUtils.h:140
DetachScopeGuard(const DetachCallback &cb=DetachCallback())
Definition: featureSet.h:131
Represents a set of characeters a DtFeature object can have.
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:101
bool DtIsElided(const FS &fs)
Helper functions using null pointers to feature sets to denote empty feature sets.
Definition: featureSet.h:463
DtLoadType
Used to indicate whether to load features.
Definition: featureSet.h:36
DtFeatureSetTemplate< DtFeature > DtFeatureSet
Definition: featureSet.h:478
DetachCallback callback
Definition: featureSet.h:128
Source feature sets are used to create your own feature sets with your own features.
Definition: featureSetUtils.h:280
DtFeatureSetWrapper< FeatureSet, boost::scoped_ptr > ScopedWrapper
Wraps a boost::scoped_ptr to a feature set.
Definition: featureSet.h:157
Scope guard which will automatically call detach callback in destructor.
Definition: featureSet.h:126
DtFeatureSet used to combine multiple feature sets into one.
Definition: featureSetList.h:21
boost::function< void()> LoadedCallback
Callback type type for async notification of feature set loading.
Definition: featureSet.h:154
static FeatureSet * Wrap(std::auto_ptr< FS > fs)
Definition: featureSet.h:201
static FeatureSet * Wrap(const boost::shared_ptr< FS > &fs)
Definition: featureSet.h:210
static DtFeatureSetTemplate * Wrap(DtFeatureSetTemplate *fs)
Definition: featureSet.h:190
DtSinkFeatureSet< FeatureSet > Sink
Definition: featureSet.h:167
Visitors allow feature sets which are implemented as compound structures of other feature sets to exp...
Definition: featureSet.h:423

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)