VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
17 
18 #include <tbb/spin_mutex.h>
19 #include <tbb/mutex.h>
20 #include <tbb/compat/condition_variable>
21 
22 #include <boost/signals2.hpp>
23 
24 namespace MAKVRinTerra
25 {
29  template <typename FS>
31  : virtual public FS
33  , public boost::enable_shared_from_this<DtAsyncLoadingFeatureSet<FS> >
34  {
35  public:
37  typedef boost::shared_ptr<DtAsyncLoadingFeatureSet> Ptr;
38 
40  typedef boost::weak_ptr<DtAsyncLoadingFeatureSet> WPtr;
41 
42  typedef FS FeatureSet;
43  typedef typename FS::Feature Feature;
44  typedef typename FeatureSet::ForEachFunction ForEachFunction;
45  typedef typename FeatureSet::LoadedCallback LoadedCallback;
46  typedef typename FeatureSet::DetachCallback DetachCallback;
47 
48  class Empty;
50 
52 
54  virtual void start();
55 
56  virtual void start(bool wait);
57 
58  std::string label() const;
59  void forEachFeatureParallel(const ForEachFunction&) const;
60  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
61  FeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
62  FeatureSet* clone() const;
63  bool loaded(double) const;
64  DetachCallback addLoadedCallback(const LoadedCallback&) const;
65  unsigned numberOfFeatures() const;
66  bool elided() 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_type<
83  void (),
84  boost::signals2::keywords::mutex_type<tbb::spin_mutex> >::type LoadedSignal;
85 
86  class Caller;
87  struct SizeCalculator;
88 
89  static bool Run(DtAsyncLoadingFeatureSet&, bool wait);
90 
92  virtual bool run(bool wait);
93 
97  virtual FeatureSet* createFeatureSet(FeatureSet* fs) const;
98 
100  virtual void inputLoadedCallback();
101 
102  struct InputLoadedCaller;
103 
104  explicit DtAsyncLoadingFeatureSet(
105  FeatureSet* input, const DtQuery& query,
106  const boost::optional<DtFeatureGeometry>& geom,
108 
111 
112  tbb::atomic<bool> myLoadingFlag;
113  tbb::atomic<bool> myRunningFlag;
114  tbb::atomic<bool> myInputLoadedFlag;
116 
118 
119  std::auto_ptr<FeatureSet> myInputFeatureSet;
121  boost::optional<DtFeatureGeometry> myGeometry;
123  };
124 
125  template <typename FS>
127  : public DtFeatureSetWrapper<FS, boost::shared_ptr>
128  , public DtObjectDebugger<typename DtAsyncLoadingFeatureSet<FS>::LoadingFeatureSet>
129  {
130  public:
131  typedef DtFeatureSetWrapper<FS, boost::shared_ptr> Base;
132 
133  class DT_DLL_features LoadingFeatureRef;
134  class DT_DLL_features LoadingFeature;
135 
136  explicit LoadingFeatureSet(const typename DtAsyncLoadingFeatureSet<FS>::Ptr&);
137 
138  explicit LoadingFeatureSet(
139  const boost::shared_ptr<FS>&,
141 
142  explicit LoadingFeatureSet(
143  FS* fs,
145 
146  std::string label() const;
147  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
148  void forEachFeatureParallel(const ForEachFunction&) const;
149  typename FS::DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
150  LoadingFeatureSet* clone() const;
151 
152  private:
153  struct WrapWithLoadingFeatureRef;
154 
155  explicit LoadingFeatureSet(const LoadingFeatureSet&);
156 
158  };
159 
160  template <typename FS>
162  : public DtAsyncLoadingFeatureSet<FS>
163  {
164  public:
165  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> Ptr;
166  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> WPtr;
170  typedef typename FeatureSet::ForEachFunction ForEachFunction;
171 
173  class QueueCallback;
174 
176 
178  void start(bool wait);
179 
181  FeatureSet* input, const DtQuery& query,
182  const boost::optional<DtFeatureGeometry>& geom,
183  const boost::shared_ptr<Queue>& queue,
185 
186  protected:
187  const boost::weak_ptr<Queue> myQueue;
188  };
189 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)