VR-Forces 4.7 Class Documentation
 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) 2015 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  , public DtObjectDebugger< DtFilteredFeatureSet<FS> >
51  {
52  public:
53  using FS::filter;
54 
55  typedef FS FeatureSet;
56  typedef typename FeatureSet::Feature Feature;
57  typedef typename FeatureSet::ForEachFunction ForEachFunction;
58  typedef typename FeatureSet::DetachCallback DetachCallback;
59  typedef typename FeatureSet::LoadedCallback LoadedCallback;
60  typedef typename FS::Visitor Visitor;
61  typedef typename FS::ConstVisitor ConstVisitor;
62 
63  DtFilteredFeatureSet(FS* fs, const DtQuery&, const boost::optional<DtFeatureGeometry>&);
64 
65  std::string label() const;
66  void forEachFeatureParallel(const ForEachFunction& func) const;
67  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
68  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
69  DtFilteredFeatureSet* clone() const;
70  bool loaded(double = 0.0) const;
71  DetachCallback addLoadedCallback(const LoadedCallback&) const;
72  unsigned numberOfFeatures() const;
73  bool elided() const;
74  bool empty() const;
75  bool isIndexed() const;
76  bool isCacheable(const boost::optional<DtFeatureGeometry>& area) const;
77  void cacheEstimate(double& time, double& size, const boost::optional<DtFeatureGeometry>& area) const;
78  void cacheData(
79  const boost::optional<DtFeatureGeometry>& area,
80  DtFeatureCacheProgressCallback* progress) const;
81 
82  void accept(Visitor&);
83  void accept(ConstVisitor&) const;
84 
85  protected:
87 
88  struct Caller;
89 
90  class Wrapper;
91  class ConstWrapper;
92 
93  std::auto_ptr<FS> myFeatureSet;
95  boost::optional<DtFeatureGeometry> myGeometry;
97  };
98 
100  template <typename FS>
102  : public FS
103  , public DtObjectDebugger< DtEmptyFeatureSet<FS> >
104  {
105  public:
106  using FS::filter;
107 
108  typedef FS FeatureSet;
109  typedef typename FeatureSet::ForEachFunction ForEachFunction;
110  typedef typename FeatureSet::DetachCallback DetachCallback;
111  typedef typename FeatureSet::LoadedCallback LoadedCallback;
112 
114 
115  std::string label() const;
116  void forEachFeatureParallel(const ForEachFunction&) const;
117  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
118  DtEmptyFeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
119  DtEmptyFeatureSet* clone() const;
120  bool loaded(double = 0.0) const;
121  DetachCallback addLoadedCallback(const LoadedCallback&) const;
122  unsigned numberOfFeatures() const;
123  bool elided() const { return true; }
124  bool empty() const { return true; }
125  };
126 
139  template <typename FS, typename F>
141  : public FS
142  , public DtObjectDebugger< DtSinkFeatureSet<FS,F> >
143  , public boost::enable_shared_from_this< DtSinkFeatureSet<FS,F> >
144  , boost::noncopyable
145  {
146  public:
147  using FS::filter;
148 
150 
151  typedef boost::shared_ptr<DtSinkFeatureSet> Ptr;
152 
153  typedef FS FeatureSet;
154  typedef typename boost::shared_ptr<F> FeaturePtr;
155 
156  typedef typename FeatureSet::ForEachFunction ForEachFunction;
157  typedef typename FeatureSet::DetachCallback DetachCallback;
158  typedef typename FeatureSet::LoadedCallback LoadedCallback;
159 
160  typedef boost::function<void (const FeaturePtr&)> ForEachPtrFunction;
161 
174 
175  template <typename Factory>
176  static Ptr Make(const DtSinkFeatureSet& fs, const Factory& factory)
177  {
178  typedef AddFeatureFactory<Factory> FactoryType;
179 
180  Ptr sink(new DtSinkFeatureSet(fs.clone()));
181 
182  if (sink->input && !sink->input->elided())
183  fs.forEachFeaturePtrAsync(FactoryType(sink, factory));
184 
185  return sink;
186  }
187 
188  static Ptr Make(FeatureSet*);
189 
190  static Ptr Make(const DtSinkFeatureSet&, const DtFeatureGeometry&);
191  static Ptr Make(const DtSinkFeatureSet&, const DtQuery&);
192 
193  std::string label() const;
194  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
195  void forEachFeatureParallel(const ForEachFunction&) const;
196  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
197  FS* clone() const;
198  bool loaded(double = 0.0) const;
199  DetachCallback addLoadedCallback(const LoadedCallback&) const;
200  unsigned numberOfFeatures() const;
201  bool elided() const;
202  bool empty() const;
203 
204  virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction&) const;
205 
206  struct ParallelCaller;
207  struct AddFeature;
208  template <typename Function> struct AddFeatureFactory;
209  struct GeometryFilterAdder;
210  struct AttributeFilterAdder;
211  struct RemoveFeature;
212  struct ParallelAdder;
213  struct RemoveCallback;
214 
215  protected:
216  explicit DtSinkFeatureSet(FS*);
217 
220  struct CallbackRecord;
221  typedef boost::shared_ptr<CallbackRecord> CallbackRecordPtr;
222 
223  struct RefRecord;
224  struct PtrRecord;
225 
226  typedef tbb::spin_rw_mutex Mutex;
227 
228  typedef std::list<CallbackRecordPtr> FeatureCallbacks;
229  typedef std::list<FeaturePtr> FeatureSequence;
230 
231  virtual void addFeatureImpl(const FeaturePtr&);
232  virtual void removeFeature(typename FeatureSequence::iterator i);
233  virtual DetachCallback addCallback(const CallbackRecordPtr& rec);
234  virtual void removeCallback(typename FeatureCallbacks::iterator i);
235 
236  mutable Mutex mutex;
237  const boost::scoped_ptr<FS> input;
240  bool deleted;
241  };
242 
243  template <typename FS>
245  : public DtSinkFeatureSet<FS, DtFeatureWrapper<typename FS::Feature> >
246  , boost::noncopyable
247  {
248  public:
250  typedef typename Base::AddFeature AddFeature;
251 
252  typedef typename Base::FeatureSet FeatureSet;
253  typedef typename Base::Feature Feature;
254  typedef typename Base::FeaturePtr FeaturePtr;
255 
256  typedef boost::shared_ptr<DtDeletingSinkFeatureSet> Ptr;
257  typedef boost::shared_ptr<const DtDeletingSinkFeatureSet> CPtr;
258 
259  static Ptr Make(FS*);
260 
262 
263  Ptr shared_from_this();
264  CPtr shared_from_this() const;
265 
266  protected:
267  explicit DtDeletingSinkFeatureSet(FS*);
268  };
269 
279  template <typename FS>
281  : public DtSinkFeatureSet<FS>
282  , public DtObjectDebugger< DtSourceFeatureSet<FS> >
283  , boost::noncopyable
284  {
285  public:
286  typedef FS FeatureSet;
289 
290  typedef typename FeatureSet::ForEachFunction ForEachFunction;
291  typedef typename FeatureSet::DetachCallback DetachCallback;
292 
293  typedef typename boost::shared_ptr<DtSourceFeatureSet> Ptr;
294 
295  static Ptr Make(FS* input = 0);
296 
298  FeaturePtr addFeature(Feature* f) { return addFeaturePtr(f); }
299  FeaturePtr addFeature(const Feature& f) { return addFeaturePtr(f.clone()); }
300  FeaturePtr addFeatureRef(const Feature& f) { return addFeature(f); }
301 
302  std::string label() const;
303 
304  bool elided() const;
305 
309 
310  virtual FeaturePtr addFeaturePtr(Feature* feature);
312 
313  protected:
314  explicit DtSourceFeatureSet(FS* input = 0);
315  };
316 }
317 

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)