VR-Forces Development_Version 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 elided() const;
71  bool empty() const;
72  bool isIndexed() const;
73 
74  void accept(Visitor&);
75  void accept(ConstVisitor&) const;
76 
77  protected:
79 
80  struct Caller;
81 
82  class Wrapper;
83  class ConstWrapper;
84 
85  std::auto_ptr<FS> myFeatureSet;
87  boost::optional<DtFeatureGeometry> myGeometry;
89  };
90 
92  template <typename FS>
94  : public FS
95  , public DtObjectDebugger< DtEmptyFeatureSet<FS> >
96  {
97  public:
98  using FS::filter;
99 
100  typedef FS FeatureSet;
101  typedef typename FeatureSet::ForEachFunction ForEachFunction;
102  typedef typename FeatureSet::DetachCallback DetachCallback;
103  typedef typename FeatureSet::LoadedCallback LoadedCallback;
104 
106 
107  std::string label() const;
108  void forEachFeatureParallel(const ForEachFunction&) const;
109  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
110  DtEmptyFeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
111  DtEmptyFeatureSet* clone() const;
112  bool loaded(double = 0.0) const;
113  DetachCallback addLoadedCallback(const LoadedCallback&) const;
114  unsigned numberOfFeatures() const;
115  bool elided() const { return true; }
116  bool empty() const { return true; }
117  };
118 
131  template <typename FS, typename F>
133  : public FS
134  , public DtObjectDebugger< DtSinkFeatureSet<FS,F> >
135  , public boost::enable_shared_from_this< DtSinkFeatureSet<FS,F> >
136  , boost::noncopyable
137  {
138  public:
139  using FS::filter;
140 
142 
143  typedef boost::shared_ptr<DtSinkFeatureSet> Ptr;
144 
145  typedef FS FeatureSet;
146  typedef typename boost::shared_ptr<F> FeaturePtr;
147 
148  typedef typename FeatureSet::ForEachFunction ForEachFunction;
149  typedef typename FeatureSet::DetachCallback DetachCallback;
150  typedef typename FeatureSet::LoadedCallback LoadedCallback;
151 
152  typedef boost::function<void (const FeaturePtr&)> ForEachPtrFunction;
153 
166 
167  template <typename Factory>
168  static Ptr Make(const DtSinkFeatureSet& fs, const Factory& factory)
169  {
170  typedef AddFeatureFactory<Factory> FactoryType;
171 
172  Ptr sink(new DtSinkFeatureSet(fs.clone()));
173 
174  if (sink->input && !sink->input->elided())
175  fs.forEachFeaturePtrAsync(FactoryType(sink, factory));
176 
177  return sink;
178  }
179 
180  static Ptr Make(FeatureSet*);
181 
182  static Ptr Make(const DtSinkFeatureSet&, const DtFeatureGeometry&);
183 
184  std::string label() const;
185  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
186  void forEachFeatureParallel(const ForEachFunction&) const;
187  DetachCallback forEachFeatureAsync(const ForEachFunction& func) const;
188  FS* clone() const;
189  bool loaded(double = 0.0) const;
190  DetachCallback addLoadedCallback(const LoadedCallback&) const;
191  unsigned numberOfFeatures() const;
192  bool elided() const;
193  bool empty() const;
194 
195  virtual DetachCallback forEachFeaturePtrAsync(const ForEachPtrFunction&) const;
196 
197  struct ParallelCaller;
198  struct AddFeature;
199  template <typename Function> struct AddFeatureFactory;
200  struct GeometryFilterAdder;
201  struct RemoveFeature;
202  struct ParallelAdder;
203  struct RemoveCallback;
204 
205  protected:
206  explicit DtSinkFeatureSet(FS*);
207 
210  struct CallbackRecord;
211  typedef boost::shared_ptr<CallbackRecord> CallbackRecordPtr;
212 
213  struct RefRecord;
214  struct PtrRecord;
215 
216  typedef tbb::spin_rw_mutex Mutex;
217 
218  typedef std::list<CallbackRecordPtr> FeatureCallbacks;
219  typedef std::list<FeaturePtr> FeatureSequence;
220 
221  virtual void addFeatureImpl(const FeaturePtr&);
222  virtual void removeFeature(typename FeatureSequence::iterator i);
223  virtual DetachCallback addCallback(const CallbackRecordPtr& rec);
224  virtual void removeCallback(typename FeatureCallbacks::iterator i);
225 
226  mutable Mutex mutex;
227  const boost::scoped_ptr<FS> input;
230  bool deleted;
231  };
232 
233  template <typename FS>
235  : public DtSinkFeatureSet<FS, DtFeatureWrapper<typename FS::Feature> >
236  , boost::noncopyable
237  {
238  public:
240  typedef typename Base::AddFeature AddFeature;
241 
242  typedef typename Base::FeatureSet FeatureSet;
243  typedef typename Base::Feature Feature;
244  typedef typename Base::FeaturePtr FeaturePtr;
245 
246  typedef boost::shared_ptr<DtDeletingSinkFeatureSet> Ptr;
247  typedef boost::shared_ptr<const DtDeletingSinkFeatureSet> CPtr;
248 
249  static Ptr Make(FS*);
250 
252 
253  Ptr shared_from_this();
254  CPtr shared_from_this() const;
255 
256  protected:
257  explicit DtDeletingSinkFeatureSet(FS*);
258  };
259 
269  template <typename FS>
271  : public DtSinkFeatureSet<FS>
272  , public DtObjectDebugger< DtSourceFeatureSet<FS> >
273  , boost::noncopyable
274  {
275  public:
276  typedef FS FeatureSet;
279 
280  typedef typename FeatureSet::ForEachFunction ForEachFunction;
281  typedef typename FeatureSet::DetachCallback DetachCallback;
282 
283  typedef typename boost::shared_ptr<DtSourceFeatureSet> Ptr;
284 
285  static Ptr Make(FS* input = 0);
286 
288  FeaturePtr addFeature(Feature* f) { return addFeaturePtr(f); }
289  FeaturePtr addFeature(const Feature& f) { return addFeaturePtr(f.clone()); }
290  FeaturePtr addFeatureRef(const Feature& f) { return addFeature(f); }
291 
292  std::string label() const;
293 
294  bool elided() const;
295 
299 
300  virtual FeaturePtr addFeaturePtr(Feature* feature);
302 
303  protected:
304  explicit DtSourceFeatureSet(FS* input = 0);
305  };
306 }
307 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)