VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
77  void accept(Visitor&);
78  void accept(ConstVisitor&) const;
79 
80  protected:
82 
83  struct Caller;
84 
85  class Wrapper;
86  class ConstWrapper;
87 
88  std::auto_ptr<FS> myFeatureSet;
90  boost::optional<DtFeatureGeometry> myGeometry;
92  };
93 
95  template <typename FS>
97  : public FS
98  , public DtObjectDebugger< DtEmptyFeatureSet<FS> >
99  {
100  public:
101  using FS::filter;
102 
103  typedef FS FeatureSet;
104  typedef typename FeatureSet::ForEachFunction ForEachFunction;
105  typedef typename FeatureSet::DetachCallback DetachCallback;
106  typedef typename FeatureSet::LoadedCallback LoadedCallback;
107 
109 
110  std::string label() const;
111  void forEachFeatureParallel(const ForEachFunction&) const;
112  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
113  DtEmptyFeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
114  DtEmptyFeatureSet* clone() const;
115  bool loaded(double = 0.0) const;
116  DetachCallback addLoadedCallback(const LoadedCallback&) const;
117  unsigned numberOfFeatures() const;
118  bool elided() const { return true; }
119  bool empty() const { return true; }
120  };
121 
134  template <typename FS, typename F>
136  : public FS
137  , public DtObjectDebugger< DtSinkFeatureSet<FS,F> >
138  , public boost::enable_shared_from_this< DtSinkFeatureSet<FS,F> >
139  , boost::noncopyable
140  {
141  public:
142  using FS::filter;
143 
145 
146  typedef boost::shared_ptr<DtSinkFeatureSet> Ptr;
147 
148  typedef FS FeatureSet;
149  typedef typename boost::shared_ptr<F> FeaturePtr;
150 
151  typedef typename FeatureSet::ForEachFunction ForEachFunction;
152  typedef typename FeatureSet::DetachCallback DetachCallback;
153  typedef typename FeatureSet::LoadedCallback LoadedCallback;
154 
155  typedef boost::function<void (const FeaturePtr&)> ForEachPtrFunction;
156 
169 
170  template <typename Factory>
171  static Ptr Make(const DtSinkFeatureSet& fs, const Factory& factory)
172  {
173  typedef AddFeatureFactory<Factory> FactoryType;
174 
175  Ptr sink(new DtSinkFeatureSet(fs.clone()));
176 
177  if (sink->input && !sink->input->elided())
178  fs.forEachFeaturePtrAsync(FactoryType(sink, factory));
179 
180  return sink;
181  }
182 
183  static Ptr Make(FeatureSet*);
184 
185  static Ptr Make(const DtSinkFeatureSet&, const DtFeatureGeometry&);
186  static Ptr Make(const DtSinkFeatureSet&, const DtQuery&);
187 
188  std::string label() const;
189  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
190  void forEachFeatureParallel(const ForEachFunction&) const;
191  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
192  FS* clone() const;
193  bool loaded(double = 0.0) const;
194  DetachCallback addLoadedCallback(const LoadedCallback&) const;
195  unsigned numberOfFeatures() const;
196  bool elided() const;
197  bool empty() const;
198 
199  virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction&) const;
200 
201  struct ParallelCaller;
202  struct AddFeature;
203  template <typename Function> struct AddFeatureFactory;
204  struct GeometryFilterAdder;
205  struct AttributeFilterAdder;
206  struct RemoveFeature;
207  struct ParallelAdder;
208  struct RemoveCallback;
209 
210  protected:
211  explicit DtSinkFeatureSet(FS*);
212 
215  struct CallbackRecord;
216  typedef boost::shared_ptr<CallbackRecord> CallbackRecordPtr;
217 
218  struct RefRecord;
219  struct PtrRecord;
220 
221  typedef tbb::spin_rw_mutex Mutex;
222 
223  typedef std::list<CallbackRecordPtr> FeatureCallbacks;
224  typedef std::list<FeaturePtr> FeatureSequence;
225 
226  virtual void addFeatureImpl(const FeaturePtr&);
227  virtual void removeFeature(typename FeatureSequence::iterator i);
228  virtual DetachCallback addCallback(const CallbackRecordPtr& rec);
229  virtual void removeCallback(typename FeatureCallbacks::iterator i);
230 
231  mutable Mutex mutex;
232  const boost::scoped_ptr<FS> input;
235  bool deleted;
236  };
237 
238  template <typename FS>
240  : public DtSinkFeatureSet<FS, DtFeatureWrapper<typename FS::Feature> >
241  , boost::noncopyable
242  {
243  public:
245  typedef typename Base::AddFeature AddFeature;
246 
247  typedef typename Base::FeatureSet FeatureSet;
248  typedef typename Base::Feature Feature;
249  typedef typename Base::FeaturePtr FeaturePtr;
250 
251  typedef boost::shared_ptr<DtDeletingSinkFeatureSet> Ptr;
252  typedef boost::shared_ptr<const DtDeletingSinkFeatureSet> CPtr;
253 
254  static Ptr Make(FS*);
255 
257 
258  Ptr shared_from_this();
259  CPtr shared_from_this() const;
260 
261  protected:
262  explicit DtDeletingSinkFeatureSet(FS*);
263  };
264 
274  template <typename FS>
276  : public DtSinkFeatureSet<FS>
277  , public DtObjectDebugger< DtSourceFeatureSet<FS> >
278  , boost::noncopyable
279  {
280  public:
281  typedef FS FeatureSet;
284 
285  typedef typename FeatureSet::ForEachFunction ForEachFunction;
286  typedef typename FeatureSet::DetachCallback DetachCallback;
287 
288  typedef typename boost::shared_ptr<DtSourceFeatureSet> Ptr;
289 
290  static Ptr Make(FS* input = 0);
291 
293  FeaturePtr addFeature(Feature* f) { return addFeaturePtr(f); }
294  FeaturePtr addFeature(const Feature& f) { return addFeaturePtr(f.clone()); }
295  FeaturePtr addFeatureRef(const Feature& f) { return addFeature(f); }
296 
297  std::string label() const;
298 
299  bool elided() const;
300 
304 
305  virtual FeaturePtr addFeaturePtr(Feature* feature);
307 
308  protected:
309  explicit DtSourceFeatureSet(FS* input = 0);
310  };
311 }
312 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)