VR-Forces 4.3 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 
40 namespace MAKVRinTerra
41 {
44  template <typename FS>
46  : public FS
47  , public DtObjectDebugger< DtFilteredFeatureSet<FS> >
48  {
49  public:
50  using FS::filter;
51 
52  typedef FS FeatureSet;
53  typedef typename FeatureSet::Feature Feature;
54  typedef typename FeatureSet::ForEachFunction ForEachFunction;
55  typedef typename FeatureSet::DetachCallback DetachCallback;
56  typedef typename FeatureSet::LoadedCallback LoadedCallback;
57  typedef typename FS::Visitor Visitor;
58  typedef typename FS::ConstVisitor ConstVisitor;
59 
60  DtFilteredFeatureSet(FS* fs, const DtQuery&, const boost::optional<DtFeatureGeometry>&);
61 
62  std::string label() const;
63  void forEachFeatureParallel(const ForEachFunction& func) const;
64  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
65  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
66  DtFilteredFeatureSet* clone() const;
67  bool loaded(double = 0.0) const;
68  DetachCallback addLoadedCallback(const LoadedCallback&) const;
69  unsigned numberOfFeatures() const;
70  bool empty() const;
71  bool isIndexed() const;
72 
73  void accept(Visitor&);
74  void accept(ConstVisitor&) const;
75 
76  protected:
78 
79  struct Caller;
80 
81  class Wrapper;
82  class ConstWrapper;
83 
84  std::auto_ptr<FS> myFeatureSet;
86  boost::optional<DtFeatureGeometry> myGeometry;
88  };
89 
91  template <typename FS>
93  : public FS
94  , public DtObjectDebugger< DtEmptyFeatureSet<FS> >
95  {
96  public:
97  using FS::filter;
98 
99  typedef FS FeatureSet;
100  typedef typename FeatureSet::ForEachFunction ForEachFunction;
101  typedef typename FeatureSet::DetachCallback DetachCallback;
102  typedef typename FeatureSet::LoadedCallback LoadedCallback;
103 
105 
106  std::string label() const;
107  void forEachFeatureParallel(const ForEachFunction&) const;
108  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
109  DtEmptyFeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
110  DtEmptyFeatureSet* clone() const;
111  bool loaded(double = 0.0) const;
112  DetachCallback addLoadedCallback(const LoadedCallback&) const;
113  unsigned numberOfFeatures() const;
114  bool empty() const { return true; }
115  };
116 
129  template <typename FS, typename F>
131  : public FS
132  , public DtObjectDebugger< DtSinkFeatureSet<FS,F> >
133  , public boost::enable_shared_from_this< DtSinkFeatureSet<FS,F> >
134  , boost::noncopyable
135  {
136  public:
137  using FS::filter;
138 
140 
141  typedef boost::shared_ptr<DtSinkFeatureSet> Ptr;
142 
143  typedef FS FeatureSet;
144  typedef typename FeatureSet::Feature Feature;
145  typedef typename boost::shared_ptr<F> FeaturePtr;
146 
147  typedef typename FeatureSet::ForEachFunction ForEachFunction;
148  typedef typename FeatureSet::DetachCallback DetachCallback;
149  typedef typename FeatureSet::LoadedCallback LoadedCallback;
150 
151  typedef boost::function<void (const typename Feature::Ptr&)> ForEachPtrFunction;
152 
165 
166  template <typename Factory>
167  static Ptr Make(const DtSinkFeatureSet& fs, const Factory& factory)
168  {
169  typedef AddFeatureFactory<Factory> FactoryType;
170 
171  Ptr sink(new DtSinkFeatureSet(fs.clone()));
172 
173  if (sink->input && !sink->input->empty())
174  fs.forEachFeaturePtrAsync(FactoryType(sink, factory));
175 
176  return sink;
177  }
178 
179  static Ptr Make(FeatureSet*);
180 
181  static Ptr Make(const DtSinkFeatureSet&, const DtFeatureGeometry&);
182 
183  std::string label() const;
184  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
185  void forEachFeatureParallel(const ForEachFunction&) const;
186  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
187  FS* clone() const;
188  bool loaded(double = 0.0) const;
189  DetachCallback addLoadedCallback(const LoadedCallback&) const;
190  unsigned numberOfFeatures() const;
191 
192  virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction&) const;
193 
194  struct ParallelCaller;
195  struct AddFeature;
196  template <typename Function> struct AddFeatureFactory;
197  struct GeometryFilterAdder;
198  struct RemoveFeature;
199  struct ParallelAdder;
200  struct RemoveCallback;
201 
202  protected:
203  explicit DtSinkFeatureSet(FS*);
204 
207  struct CallbackRecord;
208  typedef boost::shared_ptr<CallbackRecord> CallbackRecordPtr;
209 
210  struct RefRecord;
211  struct PtrRecord;
212 
213  typedef tbb::spin_rw_mutex Mutex;
214 
215  typedef std::list<CallbackRecordPtr> FeatureCallbacks;
216  typedef std::list<FeaturePtr> FeatureSequence;
217 
218  virtual void addFeatureImpl(const FeaturePtr&);
219  virtual void removeFeature(typename FeatureSequence::iterator i);
220  virtual DetachCallback addCallback(const CallbackRecordPtr& rec);
221  virtual void removeCallback(typename FeatureCallbacks::iterator i);
222 
223  mutable Mutex mutex;
224  const boost::scoped_ptr<FS> input;
227  bool deleted;
228  };
229 
230  template <typename FS>
232  : public DtSinkFeatureSet<FS, DtFeatureWrapper<typename FS::Feature> >
233  , boost::noncopyable
234  {
235  public:
237  typedef typename Base::AddFeature AddFeature;
238 
239  typedef typename Base::FeatureSet FeatureSet;
240  typedef typename Base::Feature Feature;
241  typedef typename Base::FeaturePtr FeaturePtr;
242 
243  typedef boost::shared_ptr<DtDeletingSinkFeatureSet> Ptr;
244  typedef boost::shared_ptr<const DtDeletingSinkFeatureSet> CPtr;
245 
246  static Ptr Make(FS*);
247 
249 
250  Ptr shared_from_this();
251  CPtr shared_from_this() const;
252 
253  protected:
254  explicit DtDeletingSinkFeatureSet(FS*);
255  };
256 
266  template <typename FS>
268  : public DtSinkFeatureSet<FS>
269  , public DtObjectDebugger< DtSourceFeatureSet<FS> >
270  , boost::noncopyable
271  {
272  public:
273  typedef FS FeatureSet;
276 
277  typedef typename FeatureSet::ForEachFunction ForEachFunction;
278  typedef typename FeatureSet::DetachCallback DetachCallback;
279 
280  typedef typename boost::shared_ptr<DtSourceFeatureSet> Ptr;
281 
282  static Ptr Make(FS* input = 0);
283 
285  FeaturePtr addFeature(Feature* f) { return addFeaturePtr(f); }
286  FeaturePtr addFeature(const Feature& f) { return addFeaturePtr(f.clone()); }
287  FeaturePtr addFeatureRef(const Feature& f) { return addFeature(f); }
288 
289  std::string label() const;
290 
294 
295  virtual FeaturePtr addFeaturePtr(Feature* feature);
297 
298  protected:
299  explicit DtSourceFeatureSet(FS* input = 0);
300  };
301 }
302 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)