VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
asyncLoadingFeatureSet.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <features/featureSet.h>
15 
16 #include <vrfutil/callbackQueue.h>
17 
18 #include <tbb/mutex.h>
19 #include <tbb/spin_mutex.h>
20 #include <tbb/tbb_thread.h>
21 #include <tbb/compat/condition_variable>
22 
23 #include <boost/signals2.hpp>
24 
25 namespace MAKVRinTerra
26 {
30  template <typename FS>
32  : virtual public FS
34  , public boost::enable_shared_from_this<DtAsyncLoadingFeatureSet<FS> >
35  {
36  public:
38  typedef boost::shared_ptr<DtAsyncLoadingFeatureSet> Ptr;
39 
41  typedef boost::weak_ptr<DtAsyncLoadingFeatureSet> WPtr;
42 
43  typedef FS FeatureSet;
44  typedef typename FS::Feature Feature;
45  typedef typename FeatureSet::ForEachFunction ForEachFunction;
46  typedef typename FeatureSet::LoadedCallback LoadedCallback;
47  typedef typename FeatureSet::DetachCallback DetachCallback;
48 
49  class Empty;
51 
53 
55  virtual void start();
56 
57  virtual void start(bool wait);
58 
59  std::string label() const;
60  void forEachFeatureParallel(const ForEachFunction&) const;
61  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
62  FeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
63  FeatureSet* clone() const;
64  bool loaded(double) const;
65  DetachCallback addLoadedCallback(const LoadedCallback&) const;
66  unsigned numberOfFeatures() const;
67  bool empty() const;
68 
69  unsigned size() const;
70  boost::shared_ptr<DtUnusedFeatureTileTracker::Trackable> getPtr() const;
71 
72  void load();
73  bool unload();
74  bool loading() const;
75  bool loaded() const;
76 
77  protected:
78  typedef tbb::mutex Mutex;
79  typedef tbb::interface5::condition_variable ConditionVariable;
80  typedef tbb::interface5::unique_lock<Mutex> ScopedLock;
81 
82  typedef boost::signals2::signal<void ()> LoadedSignal;
83 
84  class Caller;
85  struct SizeCalculator;
86 
87  static bool Run(DtAsyncLoadingFeatureSet&, bool wait);
88 
90  virtual bool run(bool wait);
91 
95  virtual FeatureSet* createFeatureSet(FeatureSet* fs) const;
96 
98  virtual void inputLoadedCallback();
99 
100  struct InputLoadedCaller;
101 
102  explicit DtAsyncLoadingFeatureSet(
103  FeatureSet* input, const DtQuery& query,
104  const boost::optional<DtFeatureGeometry>& geom,
106 
109 
110  tbb::atomic<bool> myLoadingFlag;
111  tbb::atomic<bool> myRunningFlag;
112  tbb::atomic<bool> myInputLoadedFlag;
114 
116 
117  std::auto_ptr<FeatureSet> myInputFeatureSet;
119  boost::optional<DtFeatureGeometry> myGeometry;
121  };
122 
123  template <typename FS>
125  : public DtFeatureSetWrapper<FS, boost::shared_ptr>
126  , public DtObjectDebugger<typename DtAsyncLoadingFeatureSet<FS>::LoadingFeatureSet>
127  {
128  public:
129  typedef DtFeatureSetWrapper<FS, boost::shared_ptr> Base;
130 
131  class DT_DLL_features LoadingFeatureRef;
132  class DT_DLL_features LoadingFeature;
133 
134  explicit LoadingFeatureSet(const typename DtAsyncLoadingFeatureSet<FS>::Ptr&);
135 
136  explicit LoadingFeatureSet(
137  const boost::shared_ptr<FS>&,
139 
140  explicit LoadingFeatureSet(
141  FS* fs,
143 
144  std::string label() const;
145  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
146  void forEachFeatureParallel(const ForEachFunction&) const;
147  typename FS::DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
148  LoadingFeatureSet* clone() const;
149 
150  private:
151  struct WrapWithLoadingFeatureRef;
152 
153  explicit LoadingFeatureSet(const LoadingFeatureSet&);
154 
156  };
157 
158  template <typename FS>
160  : public DtAsyncLoadingFeatureSet<FS>
161  {
162  public:
163  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> Ptr;
164  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> WPtr;
168  typedef typename FeatureSet::ForEachFunction ForEachFunction;
169 
171  class QueueCallback;
172 
174 
176  void start(bool wait);
177 
179  FeatureSet* input, const DtQuery& query,
180  const boost::optional<DtFeatureGeometry>& geom,
181  const boost::shared_ptr<Queue>& queue,
183 
184  protected:
185  const boost::weak_ptr<Queue> myQueue;
186  };
187 }

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)