VR-Forces 4.10 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) 2020 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 #ifdef DtObjectDebugger_Enable
129  , public DtObjectDebugger<typename DtAsyncLoadingFeatureSet<FS>::LoadingFeatureSet>
130 #endif
131  {
132  public:
134 
135  class DT_DLL_features LoadingFeatureRef;
136  class DT_DLL_features LoadingFeature;
137 
138  explicit LoadingFeatureSet(const typename DtAsyncLoadingFeatureSet<FS>::Ptr&);
139 
140  explicit LoadingFeatureSet(
141  const boost::shared_ptr<FS>&,
143 
144  explicit LoadingFeatureSet(
145  FS* fs,
147 
148  std::string label() const;
149  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
150  void forEachFeatureParallel(const ForEachFunction&) const;
151  typename FS::DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
152  LoadingFeatureSet* clone() const;
153 
154  private:
155  struct WrapWithLoadingFeatureRef;
156 
157  explicit LoadingFeatureSet(const LoadingFeatureSet&);
158 
160  };
161 
162  template <typename FS>
164  : public DtAsyncLoadingFeatureSet<FS>
165  {
166  public:
167  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> Ptr;
168  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> WPtr;
172  typedef typename FeatureSet::ForEachFunction ForEachFunction;
173 
175  class QueueCallback;
176 
178 
180  void start(bool wait);
181 
183  FeatureSet* input, const DtQuery& query,
184  const boost::optional<DtFeatureGeometry>& geom,
185  const boost::shared_ptr<Queue>& queue,
187 
188  protected:
189  const boost::weak_ptr<Queue> myQueue;
190  };
191 }
boost::weak_ptr< DtAsyncLoadingFeatureSet > WPtr
Weak pointer.
Definition: asyncLoadingFeatureSet.h:40
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
FS FeatureSet
Definition: asyncLoadingFeatureSet.h:42
FeatureSet::LoadedCallback LoadedCallback
Definition: asyncLoadingFeatureSet.h:45
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:44
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:172
DtAsyncLoadingFeatureSet< FS >::WPtr BaseWPtr
Definition: asyncLoadingFeatureSet.h:170
boost::shared_ptr< DtAsyncLoadingFeatureSet > Ptr
Shared pointer.
Definition: asyncLoadingFeatureSet.h:37
ConditionVariable myWaitCondition
Definition: asyncLoadingFeatureSet.h:110
boost::optional< DtFeatureGeometry > myGeometry
Definition: asyncLoadingFeatureSet.h:121
DtFeatureSetWrapper< FeatureSet, boost::shared_ptr > myFeatureSet
Definition: asyncLoadingFeatureSet.h:122
Definition: asyncLoadingFeatureSet.h:163
const boost::weak_ptr< Queue > myQueue
Definition: asyncLoadingFeatureSet.h:189
tbb::interface5::unique_lock< Mutex > ScopedLock
Definition: asyncLoadingFeatureSet.h:80
std::string label() const
Only used for output, won&#39;t change operation.
voidpf void uLong size
Definition: ioapi.h:39
boost::shared_ptr< Sentinel > Ptr
Definition: unusedFeatureTileTracker.h:235
Default on in debug, off in release.
Definition: objectCounter.h:31
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
tbb::interface5::condition_variable ConditionVariable
Definition: asyncLoadingFeatureSet.h:79
tbb::mutex Mutex
Definition: asyncLoadingFeatureSet.h:78
boost::shared_ptr< DtQueueLoadingFeatureSet > WPtr
Definition: asyncLoadingFeatureSet.h:168
DtVrfCallbackQueue Queue
Definition: asyncLoadingFeatureSet.h:174
tbb::atomic< bool > myInputLoadedFlag
actually running
Definition: asyncLoadingFeatureSet.h:114
Loads a feature set using a user supplied threading policy.
Definition: asyncLoadingFeatureSet.h:30
boost::shared_ptr< DtUnusedFeatureTileTracker > Ptr
Definition: unusedFeatureTileTracker.h:52
Mixin interface for classes which wish to be tracked.
Definition: unusedFeatureTileTracker.h:145
Represents a set of characeters a DtFeature object can have.
Definition: query.h:38
FS::Feature Feature
Definition: asyncLoadingFeatureSet.h:43
bool myLoadedFlag
input feature set has finished loading
Definition: asyncLoadingFeatureSet.h:115
FeatureSet::DetachCallback DetachCallback
Definition: asyncLoadingFeatureSet.h:46
Mutex myConditionMutex
Definition: asyncLoadingFeatureSet.h:109
LoadedSignal myLoadedSignal
wrapped feature set created
Definition: asyncLoadingFeatureSet.h:117
DetachCallback forEachFeatureAsync(const ForEachFunction &) const
boost::signals2::signal_type< void(), boost::signals2::keywords::mutex_type< tbb::spin_mutex > >::type LoadedSignal
Definition: asyncLoadingFeatureSet.h:84
DtLoadType
Used to indicate whether to load features.
Definition: featureSet.h:36
DtQuery myQuery
Definition: asyncLoadingFeatureSet.h:120
tbb::atomic< bool > myLoadingFlag
Definition: asyncLoadingFeatureSet.h:112
DtFeatureSetWrapper< FS, boost::shared_ptr > Base
Definition: asyncLoadingFeatureSet.h:133
boost::shared_ptr< DtQueueLoadingFeatureSet > Ptr
Definition: asyncLoadingFeatureSet.h:167
std::auto_ptr< FeatureSet > myInputFeatureSet
Definition: asyncLoadingFeatureSet.h:119
Definition: asyncLoadingFeatureSet.h:126
DtUnusedFeatureTileTracker::Sentinel::Ptr mySentinel
Definition: asyncLoadingFeatureSet.h:159
void forEachFeatureParallel(const ForEachFunction &) const
tbb::atomic< bool > myRunningFlag
requested to load
Definition: asyncLoadingFeatureSet.h:113
class DT_DLL_features LoadingFeatureSet
Definition: asyncLoadingFeatureSet.h:49
FeatureSet * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
DtAsyncLoadingFeatureSet< FS >::Ptr BasePtr
Definition: asyncLoadingFeatureSet.h:169
DtAsyncLoadingFeatureSet< FS >::FeatureSet FeatureSet
Definition: asyncLoadingFeatureSet.h:171

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)