VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
featureSet.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2014 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <memory>
15 #include <string>
16 
17 #include <boost/function.hpp>
18 #include <boost/scoped_ptr.hpp>
19 #include <boost/shared_ptr.hpp>
20 #include <boost/weak_ptr.hpp>
21 
22 #include <boost/optional.hpp>
23 #include <boost/noncopyable.hpp>
24 
25 #include <vrfutil/objectCounter.h>
27 
28 namespace MAKVRinTerra
29 {
30  class DtFeature;
31  class DtQuery;
32  class DtFeatureGeometry;
33 
37  {
46  };
47 
48  template <
49  typename FS,
50  template <typename> class PtrTemplate = boost::scoped_ptr,
51  typename InnerFS = FS>
52  class DtFeatureSetWrapper;
53 
55  {
56  public:
58  };
59 
60  template <typename FS, typename InnerFS = FS>
62 
63  template <size_t N, typename FS, typename InnerFS = FS>
65 
66  template <typename FS>
68 
69  template <typename FS>
71 
72  template <typename FS, typename F = typename FS::Feature>
74 
75  template <typename FS>
77 
92  template <typename F>
94  : private boost::noncopyable
95  , public DtObjectDebugger< DtFeatureSetTemplate<F> >
96  {
97  public:
99  typedef F Feature;
100 
103 
115  typedef boost::function<void ()> DetachCallback;
116 
118  class DetachScopeGuard : boost::noncopyable
119  {
121 
122  public:
124  callback(cb) {};
126  {
127  if (callback)
128  {
129  callback();
130  }
131  };
132 
133  void reset(const DetachCallback& cb = DetachCallback())
134  {
135  if (callback)
136  callback();
137 
138  callback = cb;
139  };
140  };
141 
143  typedef boost::function<void (const Feature&)> ForEachFunction;
144 
146  typedef boost::function<void ()> LoadedCallback;
147 
150 
153 
155 
162 
175  template <typename FS>
176  static FeatureSet* Wrap(FS* fs)
177  {
178  std::auto_ptr<FS> set(fs);
179  return Wrap(set);
180  }
181 
183  {
184  return fs;
185  }
186 
187  static DtFeatureSetTemplate* Wrap(std::auto_ptr<FeatureSet> fs)
188  {
189  return fs.release();
190  }
191 
192  template <typename FS>
193  static FeatureSet* Wrap(std::auto_ptr<FS> fs)
194  {
195  if (!fs.get() || fs->elided())
196  return 0;
197 
199  }
200 
201  template <typename FS>
202  static FeatureSet* Wrap(const boost::shared_ptr<FS>& fs)
203  {
204  if (!fs || fs->elided())
205  return 0;
206 
208  }
209 
210  template <typename FS>
211  static FeatureSet* Wrap(const boost::weak_ptr<FS>& fs)
212  {
213  boost::shared_ptr<FS> ptr(fs.lock());
214  if (!ptr || ptr->elided())
215  return 0;
216 
218  }
220 
222  virtual ~DtFeatureSetTemplate();
223 
227  virtual std::string label() const = 0;
228 
236  virtual void forEachFeatureParallel(const ForEachFunction& func) const = 0;
237 
239  void forEachFeature(const ForEachFunction& func) const;
240 
243 
244  bool forEachFeatureParallelBlock(const ForEachFunction& func, double timeout = 60) const;
245  bool forEachFeatureBlock(const ForEachFunction& func, double timeout = 60) const;
247 
272  virtual DetachCallback forEachFeatureAsync(const ForEachFunction& func) const = 0;
274 
285 
286  virtual DtFeatureSetTemplate* filter(
287  const DtQuery& query,
288  const boost::optional<DtFeatureGeometry>& geometry,
289  DtLoadType load) const;
290 
291  DtFeatureSetTemplate* filter(
292  const DtQuery& query, DtLoadType load) const;
293 
294  DtFeatureSetTemplate* filter(
295  const boost::optional<DtFeatureGeometry>& geometry, DtLoadType load) const;
297 
304 
305  virtual bool load(
306  const DtQuery& query,
307  const boost::optional<DtFeatureGeometry>& geometry) const;
308 
309  bool load(const DtQuery& query) const;
310  bool load(const boost::optional<DtFeatureGeometry>& geometry) const;
312 
319  virtual DtFeatureSetTemplate* clone() const = 0;
320 
338  virtual bool loaded(double timeout=0.0) const = 0;
339 
349  virtual DetachCallback addLoadedCallback(const LoadedCallback&) const = 0;
350 
360  virtual bool elided() const = 0;
361 
369  virtual bool empty() const = 0;
370 
373  virtual bool isIndexed() const;
374 
389  virtual unsigned numberOfFeatures() const;
390 
395 
396  class Visitor
397  {
398  public:
399  virtual ~Visitor();
400  virtual void visit(FeatureSet&) = 0;
401  };
402 
404  {
405  public:
406  virtual ~ConstVisitor();
407  virtual void visit(const FeatureSet&) = 0;
408  };
410 
415 
416  virtual void accept(Visitor&);
417  virtual void accept(ConstVisitor&) const;
419 
420  protected:
421  class SynchronizedFunction;
422  struct FeatureCounter;
423  };
424 
426  template <typename F>
428  {
429  return from.clone();
430  }
431 
434 
435  template <typename FS>
436  inline bool DtIsElided(const FS& fs)
437  {
438  return fs.elided();
439  }
440 
441  template <typename FS>
442  inline bool DtIsElided(FS* fs)
443  {
444  if (!fs)
445  return true;
446 
447  return DtIsElided(*fs);
448  }
450 
452 }
453 
455 #define DT_INSTANTIATE_FEATURE_SETS(F) \
456  template class MAKVRinTerra::DtFeatureSetTemplate<F>; \
457  template class MAKVRinTerra::DtFeatureSetList< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
458  template class MAKVRinTerra::DtFeatureSetArray<4, MAKVRinTerra::DtFeatureSetTemplate<F> >; \
459  template class MAKVRinTerra::DtFilteredFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
460  template class MAKVRinTerra::DtEmptyFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
461  template class MAKVRinTerra::DtSinkFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
462  template class MAKVRinTerra::DtSourceFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
463  template class MAKVRinTerra::DtAsyncLoadingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
464  template class MAKVRinTerra::DtPagingFeatureSet< MAKVRinTerra::DtFeatureSetTemplate<F> >; \
465 

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)