VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
featureSetUtils.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/featureSet.h>
13 #include <features/query.h>
14 
15 #include <vector>
16 
17 #include <boost/scoped_ptr.hpp>
18 #include <boost/shared_ptr.hpp>
19 
20 #include <tbb/spin_rw_mutex.h>
21 
24 
27 
30 
33 
36 
39 
42 
43 namespace MAKVRinTerra
44 {
47  template <typename FS>
49  : public FS
50 #ifdef DtObjectDebugger_Enable
51  , public DtObjectDebugger< DtFilteredFeatureSet<FS> >
52 #endif
53  {
54  public:
55  using FS::filter;
56 
57  typedef FS FeatureSet;
58  typedef typename FeatureSet::Feature Feature;
59  typedef typename FeatureSet::ForEachFunction ForEachFunction;
60  typedef typename FeatureSet::DetachCallback DetachCallback;
61  typedef typename FeatureSet::LoadedCallback LoadedCallback;
62  typedef typename FS::Visitor Visitor;
63  typedef typename FS::ConstVisitor ConstVisitor;
64 
65  DtFilteredFeatureSet(FS* fs, const DtQuery&, const boost::optional<DtFeatureGeometry>&);
66 
67  std::string label() const;
68  void forEachFeatureParallel(const ForEachFunction& func) const;
69  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
70  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
71  DtFilteredFeatureSet* clone() const;
72  bool loaded(double = 0.0) const;
73  DetachCallback addLoadedCallback(const LoadedCallback&) const;
74  unsigned numberOfFeatures() const;
75  bool elided() const;
76  bool empty() const;
77  bool isIndexed() const;
78  bool isCacheable(const boost::optional<DtFeatureGeometry>& area) const;
79  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
80  void cacheData(
81  const boost::optional<DtFeatureGeometry>& area,
82  DtFeatureCacheProgressCallback* progress) const;
83 
84  void accept(Visitor&);
85  void accept(ConstVisitor&) const;
86 
87  protected:
89 
90  struct Caller;
91 
92  class Wrapper;
93  class ConstWrapper;
94 
95  std::auto_ptr<FS> myFeatureSet;
97  boost::optional<DtFeatureGeometry> myGeometry;
99  };
100 
102  template <typename FS>
104  : public FS
105 #ifdef DtObjectDebugger_Enable
106  , public DtObjectDebugger< DtEmptyFeatureSet<FS> >
107 #endif
108  {
109  public:
110  using FS::filter;
111 
112  typedef FS FeatureSet;
113  typedef typename FeatureSet::ForEachFunction ForEachFunction;
114  typedef typename FeatureSet::DetachCallback DetachCallback;
115  typedef typename FeatureSet::LoadedCallback LoadedCallback;
116 
118 
119  std::string label() const;
120  void forEachFeatureParallel(const ForEachFunction&) const;
121  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
122  DtEmptyFeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
123  DtEmptyFeatureSet* clone() const;
124  bool loaded(double = 0.0) const;
125  DetachCallback addLoadedCallback(const LoadedCallback&) const;
126  unsigned numberOfFeatures() const;
127  bool elided() const { return true; }
128  bool empty() const { return true; }
129  };
130 
143  template <typename FS, typename F>
145  : public FS
146 #ifdef DtObjectDebugger_Enable
147  , public DtObjectDebugger< DtSinkFeatureSet<FS,F> >
148 #endif
149  , public boost::enable_shared_from_this< DtSinkFeatureSet<FS,F> >
150  , boost::noncopyable
151  {
152  public:
153  using FS::filter;
154 
156 
157  typedef boost::shared_ptr<DtSinkFeatureSet> Ptr;
158 
159  typedef FS FeatureSet;
160  typedef typename boost::shared_ptr<F> FeaturePtr;
161 
162  typedef typename FeatureSet::ForEachFunction ForEachFunction;
163  typedef typename FeatureSet::DetachCallback DetachCallback;
164  typedef typename FeatureSet::LoadedCallback LoadedCallback;
165 
166  typedef boost::function<void (const FeaturePtr&)> ForEachPtrFunction;
167 
180 
181  template <typename Factory>
182  static Ptr Make(const DtSinkFeatureSet& fs, const Factory& factory)
183  {
184  typedef AddFeatureFactory<Factory> FactoryType;
185 
186  Ptr sink(new DtSinkFeatureSet(fs.clone()));
187 
188  if (sink->input && !sink->input->elided())
189  fs.forEachFeaturePtrAsync(FactoryType(sink, factory));
190 
191  return sink;
192  }
193 
194  static Ptr Make(FeatureSet*);
195 
196  static Ptr Make(const DtSinkFeatureSet&, const DtFeatureGeometry&);
197  static Ptr Make(const DtSinkFeatureSet&, const DtQuery&);
198 
199  std::string label() const;
200  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
201  void forEachFeatureParallel(const ForEachFunction&) const;
202  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
203  FS* clone() const;
204  bool loaded(double = 0.0) const;
205  DetachCallback addLoadedCallback(const LoadedCallback&) const;
206  unsigned numberOfFeatures() const;
207  bool elided() const;
208  bool empty() const;
209 
210  virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction&) const;
211 
212  struct ParallelCaller;
213  struct AddFeature;
214  template <typename Function> struct AddFeatureFactory;
215  struct GeometryFilterAdder;
216  struct AttributeFilterAdder;
217  struct RemoveFeature;
218  struct ParallelAdder;
219  struct RemoveCallback;
220 
221  protected:
222  explicit DtSinkFeatureSet(FS*);
223 
226  struct CallbackRecord;
227  typedef boost::shared_ptr<CallbackRecord> CallbackRecordPtr;
228 
229  struct RefRecord;
230  struct PtrRecord;
231 
232  typedef tbb::spin_rw_mutex Mutex;
233 
234  typedef std::list<CallbackRecordPtr> FeatureCallbacks;
235  typedef std::list<FeaturePtr> FeatureSequence;
236 
237  virtual void addFeatureImpl(const FeaturePtr&);
238  virtual void removeFeature(typename FeatureSequence::iterator i);
239  virtual DetachCallback addCallback(const CallbackRecordPtr& rec);
240  virtual void removeCallback(typename FeatureCallbacks::iterator i);
241 
242  mutable Mutex mutex;
243  const boost::scoped_ptr<FS> input;
246  bool deleted;
247  };
248 
249  template <typename FS>
251  : public DtSinkFeatureSet<FS, DtFeatureWrapper<typename FS::Feature> >
252  , boost::noncopyable
253  {
254  public:
256  typedef typename Base::AddFeature AddFeature;
257 
258  typedef typename Base::FeatureSet FeatureSet;
259  typedef typename Base::Feature Feature;
260  typedef typename Base::FeaturePtr FeaturePtr;
261 
262  typedef boost::shared_ptr<DtDeletingSinkFeatureSet> Ptr;
263  typedef boost::shared_ptr<const DtDeletingSinkFeatureSet> CPtr;
264 
265  static Ptr Make(FS*);
266 
268 
269  Ptr shared_from_this();
270  CPtr shared_from_this() const;
271 
272  protected:
273  explicit DtDeletingSinkFeatureSet(FS*);
274  };
275 
285  template <typename FS>
287  : public DtSinkFeatureSet<FS>
288 #ifdef DtObjectDebugger_Enable
289  , public DtObjectDebugger< DtSourceFeatureSet<FS> >
290 #endif
291  , boost::noncopyable
292  {
293  public:
294  typedef FS FeatureSet;
297 
298  typedef typename FeatureSet::ForEachFunction ForEachFunction;
299  typedef typename FeatureSet::DetachCallback DetachCallback;
300 
301  typedef typename boost::shared_ptr<DtSourceFeatureSet> Ptr;
302 
303  static Ptr Make(FS* input = 0);
304 
306  FeaturePtr addFeature(Feature* f) { return addFeaturePtr(f); }
307  FeaturePtr addFeature(const Feature& f) { return addFeaturePtr(f.clone()); }
308  FeaturePtr addFeatureRef(const Feature& f) { return addFeature(f); }
309 
310  std::string label() const;
311 
312  bool elided() const;
313 
317 
318  virtual FeaturePtr addFeaturePtr(Feature* feature);
320 
321  protected:
322  explicit DtSourceFeatureSet(FS* input = 0);
323  };
324 }
325 
DtQuery myQuery
Definition: featureSetUtils.h:96
DtFeatureSet which filters out features from a feature set. Wraps a feature set with a geometry and q...
Definition: featureSetUtils.h:48
Definition: featureSetUtils.h:28
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
FS FeatureSet
Definition: featureSetUtils.h:112
FeatureSet::LoadedCallback LoadedCallback
Definition: featureSetUtils.h:164
FeatureSet::LoadedCallback LoadedCallback
Definition: featureSetUtils.h:115
static Ptr Make(const DtSinkFeatureSet &fs, const Factory &factory)
template &lt;typename factory&gt;=&quot;&quot;&gt; static Ptr Make(FS*, const Factory&amp; factory) { typedef AddFeatureFact...
Definition: featureSetUtils.h:182
FS FeatureSet
Definition: featureSetUtils.h:159
Base::FeaturePtr FeaturePtr
Definition: featureSetUtils.h:260
FeatureSet::ForEachFunction ForEachFunction
Definition: featureSetUtils.h:162
FeaturePtr addFeatureRef(const Feature &f)
Definition: featureSetUtils.h:308
Definition: featureSetUtils.h:37
Definition: featureSetUtils.h:25
boost::shared_ptr< DtSourceFeatureSet > Ptr
Definition: featureSetUtils.h:301
const boost::scoped_ptr< FS > input
Definition: featureSetUtils.h:243
FS::ConstVisitor ConstVisitor
Definition: featureSetUtils.h:63
FeaturePtr addFeature(const Feature &f)
Definition: featureSetUtils.h:307
virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction &) const
tbb::spin_rw_mutex Mutex
Definition: featureSetUtils.h:230
Base::Feature Feature
Definition: featureSetUtils.h:259
voidpf void uLong size
Definition: ioapi.h:39
FeaturePtr addFeature(Feature *f)
these functions make it easier to take the address of addFeature
Definition: featureSetUtils.h:306
FeatureSet::DetachCallback DetachCallback
Definition: featureSetUtils.h:60
FeatureSet::ForEachFunction ForEachFunction
Definition: featureSetUtils.h:113
Base::AddFeature AddFeature
Definition: featureSetUtils.h:256
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
std::list< FeaturePtr > FeatureSequence
Definition: featureSetUtils.h:235
Default on in debug, off in release.
Definition: objectCounter.h:31
boost::shared_ptr< const DtDeletingSinkFeatureSet > CPtr
Definition: featureSetUtils.h:263
boost::optional< DtFeatureGeometry > myGeometry
Definition: featureSetUtils.h:97
class DT_DLL_features DtEmptyFeatureSet
Definition: featureSet.h:78
FeatureSet::ForEachFunction ForEachFunction
Definition: featureSetUtils.h:298
FeatureSet::Feature Feature
Definition: featureSetUtils.h:58
bool empty() const
Definition: featureSetUtils.h:128
class DT_DLL_features DtSinkFeatureSet
Definition: featureSet.h:81
Feature set object which will take another feature set, iterate over its contents asynchronously and ...
Definition: featureSetUtils.h:144
Definition: featureSetUtils.h:31
Definition: featureSetUtils.h:22
FeatureSequence features
callbacks for new features
Definition: featureSetUtils.h:245
Represents a set of characeters a DtFeature object can have. DtQuery objects are the way to communica...
Definition: query.h:38
bool elided() const
Definition: featureSetUtils.h:127
boost::shared_ptr< F > FeaturePtr
Definition: featureSetUtils.h:160
class DT_DLL_features DtSourceFeatureSet
Definition: featureSet.h:84
FeatureSet::DetachCallback DetachCallback
Definition: featureSetUtils.h:163
FeatureCallbacks featureCallbacks
feature set to read from
Definition: featureSetUtils.h:244
DtSinkFeatureSet< FS >::Feature Feature
Definition: featureSetUtils.h:295
FS FeatureSet
Definition: featureSetUtils.h:57
#define DT_DEFINE_OBJECT_DEBUGGER_NAME_TEMPLATE(type)
Definition: objectCounter.h:275
Definition: featureSetUtils.h:214
FS::Visitor Visitor
Definition: featureSetUtils.h:62
Definition: featureSetUtils.h:34
boost::function< void(const FeaturePtr &)> ForEachPtrFunction
Definition: featureSetUtils.h:166
boost::shared_ptr< DtSinkFeatureSet > Ptr
Definition: featureSetUtils.h:157
bool myEmptyFlag
Definition: featureSetUtils.h:98
boost::shared_ptr< CallbackRecord > CallbackRecordPtr
Definition: featureSetUtils.h:226
std::auto_ptr< FS > myFeatureSet
Definition: featureSetUtils.h:93
DtSinkFeatureSet< FS >::FeaturePtr FeaturePtr
Definition: featureSetUtils.h:296
DtSinkFeatureSet Base
Definition: featureSetUtils.h:155
Dummy feature set which contains no features.
Definition: featureSetUtils.h:103
Base::FeatureSet FeatureSet
Definition: featureSetUtils.h:258
DtLoadType
Used to indicate whether to load features. See DtFeatureSetTemplate::filter.
Definition: featureSet.h:36
Source feature sets are used to create your own feature sets with your own features.
Definition: featureSetUtils.h:286
boost::shared_ptr< DtDeletingSinkFeatureSet > Ptr
Definition: featureSetUtils.h:262
FeatureSet::DetachCallback DetachCallback
Definition: featureSetUtils.h:114
FS FeatureSet
Definition: featureSetUtils.h:294
Definition: featureSetUtils.h:40
FeatureSet::LoadedCallback LoadedCallback
Definition: featureSetUtils.h:61
FeatureSet::ForEachFunction ForEachFunction
Definition: featureSetUtils.h:59
Definition: featureSetUtils.h:250
bool deleted
saved features
Definition: featureSetUtils.h:246
DtSinkFeatureSet< FS, DtFeatureWrapper< typename FS::Feature > > Base
Definition: featureSetUtils.h:255
class DT_DLL_features DtFilteredFeatureSet
Definition: featureSet.h:75
Represents a feature geometry.
Definition: featureGeometry.h:39
FeatureSet::DetachCallback DetachCallback
Definition: featureSetUtils.h:299
std::list< CallbackRecordPtr > FeatureCallbacks
Definition: featureSetUtils.h:234
Mutex mutex
Definition: featureSetUtils.h:242

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)