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

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)