VR-Forces Developer's Guide
 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 
21 #include <boost/signals2.hpp>
22 
23 namespace MAKVRinTerra
24 {
28  template <typename FS>
30  : virtual public FS
32  , public std::enable_shared_from_this<DtAsyncLoadingFeatureSet<FS> >
33  {
34  public:
36  typedef std::shared_ptr<DtAsyncLoadingFeatureSet> Ptr;
37 
39  typedef std::weak_ptr<DtAsyncLoadingFeatureSet> WPtr;
40 
41  typedef FS FeatureSet;
42  typedef typename FS::Feature Feature;
43  typedef typename FeatureSet::ForEachFunction ForEachFunction;
44  typedef typename FeatureSet::LoadedCallback LoadedCallback;
45  typedef typename FeatureSet::DetachCallback DetachCallback;
46 
47  class Empty;
49 
50  virtual ~DtAsyncLoadingFeatureSet() override;
51 
53  virtual void start();
54 
55  virtual void start(bool wait);
56 
57  virtual std::string label() const override;
58  void forEachFeatureParallel(const ForEachFunction&) const;
59  DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
60  FeatureSet* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
61  FeatureSet* clone() const;
62  bool loaded(double) const;
63  DetachCallback addLoadedCallback(const LoadedCallback&) const;
64  unsigned numberOfFeatures() const;
65  bool elided() const;
66  bool empty() const;
67 
68  virtual unsigned size() const override;
69  virtual std::shared_ptr<DtUnusedFeatureTileTracker::Trackable> getPtr() const override;
70 
71  virtual void load() override;
72  virtual bool unload() override;
73  virtual bool loading() const override;
74  virtual bool loaded() const override;
75 
76  protected:
77  typedef std::mutex Mutex;
78  typedef std::condition_variable ConditionVariable;
79  typedef std::unique_lock<Mutex> ScopedLock;
80 
81  typedef boost::signals2::signal_type<
82  void (),
83  boost::signals2::keywords::mutex_type<tbb::spin_mutex> >::type LoadedSignal;
84 
85  class Caller;
86  struct SizeCalculator;
87 
88  static bool Run(DtAsyncLoadingFeatureSet&, bool wait);
89 
91  virtual bool run(bool wait);
92 
96  virtual FeatureSet* createFeatureSet(FeatureSet* fs) const;
97 
99  virtual void inputLoadedCallback();
100 
101  struct InputLoadedCaller;
102 
103  explicit DtAsyncLoadingFeatureSet(
104  FeatureSet* input, const DtQuery& query,
105  const boost::optional<DtFeatureGeometry>& geom,
107 
110 
111  std::atomic_bool myLoadingFlag;
112  std::atomic_bool myRunningFlag;
113  std::atomic_bool myInputLoadedFlag;
115 
117 
118  std::unique_ptr<FeatureSet> myInputFeatureSet;
120  boost::optional<DtFeatureGeometry> myGeometry;
122  };
123 
124  template <typename FS>
126  : public DtFeatureSetWrapper<FS, std::shared_ptr>
127 #ifdef DtObjectDebugger_Enable
128  , public DtObjectDebugger<typename DtAsyncLoadingFeatureSet<FS>::LoadingFeatureSet>
129 #endif
130  {
131  public:
133 
134  class DT_DLL_features LoadingFeatureRef;
135  class DT_DLL_features LoadingFeature;
136 
137  explicit LoadingFeatureSet(const typename DtAsyncLoadingFeatureSet<FS>::Ptr&);
138 
139  explicit LoadingFeatureSet(
140  const std::shared_ptr<FS>&,
142 
143  explicit LoadingFeatureSet(
144  FS* fs,
146 
147  std::string label() const;
148  FS* filter(const DtQuery&, const boost::optional<DtFeatureGeometry>&, DtLoadType) const;
149  void forEachFeatureParallel(const ForEachFunction&) const;
150  typename FS::DetachCallback forEachFeatureAsync(const ForEachFunction&) const;
151  LoadingFeatureSet* clone() const;
152 
153  private:
154  struct WrapWithLoadingFeatureRef;
155 
156  explicit LoadingFeatureSet(const LoadingFeatureSet&);
157 
159  };
160 
161  template <typename FS>
163  : public DtAsyncLoadingFeatureSet<FS>
164  {
165  public:
166  typedef std::shared_ptr<DtQueueLoadingFeatureSet> Ptr;
167  typedef std::shared_ptr<DtQueueLoadingFeatureSet> WPtr;
171  typedef typename FeatureSet::ForEachFunction ForEachFunction;
172 
174  class QueueCallback;
175 
177 
179  virtual void start(bool wait) override;
180 
182  FeatureSet* input, const DtQuery& query,
183  const boost::optional<DtFeatureGeometry>& geom,
184  const std::shared_ptr<Queue>& queue,
186 
187  protected:
188  const std::weak_ptr<Queue> myQueue;
189  };
190 }
std::unique_lock< Mutex > ScopedLock
Definition: asyncLoadingFeatureSet.h:79
#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:41
FeatureSet::LoadedCallback LoadedCallback
Definition: asyncLoadingFeatureSet.h:44
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:43
std::atomic_bool myRunningFlag
requested to load
Definition: asyncLoadingFeatureSet.h:112
FeatureSet::ForEachFunction ForEachFunction
Definition: asyncLoadingFeatureSet.h:171
std::shared_ptr< DtQueueLoadingFeatureSet > Ptr
Definition: asyncLoadingFeatureSet.h:166
DtAsyncLoadingFeatureSet< FS >::WPtr BaseWPtr
Definition: asyncLoadingFeatureSet.h:169
ConditionVariable myWaitCondition
Definition: asyncLoadingFeatureSet.h:109
boost::optional< DtFeatureGeometry > myGeometry
Definition: asyncLoadingFeatureSet.h:120
Definition: asyncLoadingFeatureSet.h:162
std::shared_ptr< DtAsyncLoadingFeatureSet > Ptr
Shared pointer.
Definition: asyncLoadingFeatureSet.h:36
std::shared_ptr< DtUnusedFeatureTileTracker > Ptr
Definition: unusedFeatureTileTracker.h:49
voidpf void uLong size
Definition: ioapi.h:39
Default on in debug, off in release.
Definition: objectCounter.h:27
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:29
std::shared_ptr< Sentinel > Ptr
Definition: unusedFeatureTileTracker.h:232
DtFeatureSetWrapper< FeatureSet, std::shared_ptr > myFeatureSet
Definition: asyncLoadingFeatureSet.h:121
Definition: featureSet.h:64
std::weak_ptr< DtAsyncLoadingFeatureSet > WPtr
Weak pointer.
Definition: asyncLoadingFeatureSet.h:39
DtVrfCallbackQueue Queue
Definition: asyncLoadingFeatureSet.h:173
Loads a feature set using a user supplied threading policy. This class uses std::enable_shared_from_t...
Definition: asyncLoadingFeatureSet.h:29
std::mutex Mutex
Definition: asyncLoadingFeatureSet.h:77
Mixin interface for classes which wish to be tracked.
Definition: unusedFeatureTileTracker.h:142
Represents a set of characeters a DtFeature object can have. DtQuery objects are the way to communica...
Definition: query.h:37
FS::Feature Feature
Definition: asyncLoadingFeatureSet.h:42
std::unique_ptr< FeatureSet > myInputFeatureSet
Definition: asyncLoadingFeatureSet.h:118
bool myLoadedFlag
input feature set has finished loading
Definition: asyncLoadingFeatureSet.h:114
FeatureSet::DetachCallback DetachCallback
Definition: asyncLoadingFeatureSet.h:45
Mutex myConditionMutex
Definition: asyncLoadingFeatureSet.h:108
LoadedSignal myLoadedSignal
wrapped feature set created
Definition: asyncLoadingFeatureSet.h:116
DtFeatureSetWrapper< FS, std::shared_ptr > Base
Definition: asyncLoadingFeatureSet.h:132
std::condition_variable ConditionVariable
Definition: asyncLoadingFeatureSet.h:78
const std::weak_ptr< Queue > myQueue
Definition: asyncLoadingFeatureSet.h:188
std::atomic_bool myInputLoadedFlag
actually running
Definition: asyncLoadingFeatureSet.h:113
virtual std::string label() const override
Only used for output, won&#39;t change operation.
DetachCallback forEachFeatureAsync(const ForEachFunction &) const
boost::signals2::signal_type< void(), boost::signals2::keywords::mutex_type< tbb::spin_mutex > >::type LoadedSignal
Definition: asyncLoadingFeatureSet.h:83
DtLoadType
Used to indicate whether to load features. See DtFeatureSetTemplate::filter.
Definition: featureSet.h:33
DtQuery myQuery
Definition: asyncLoadingFeatureSet.h:119
std::shared_ptr< DtQueueLoadingFeatureSet > WPtr
Definition: asyncLoadingFeatureSet.h:167
Definition: asyncLoadingFeatureSet.h:125
DtUnusedFeatureTileTracker::Sentinel::Ptr mySentinel
Definition: asyncLoadingFeatureSet.h:158
void forEachFeatureParallel(const ForEachFunction &) const
class DT_DLL_features LoadingFeatureSet
Definition: asyncLoadingFeatureSet.h:48
std::atomic_bool myLoadingFlag
Definition: asyncLoadingFeatureSet.h:111
FeatureSet * filter(const DtQuery &, const boost::optional< DtFeatureGeometry > &, DtLoadType) const
DtAsyncLoadingFeatureSet< FS >::Ptr BasePtr
Definition: asyncLoadingFeatureSet.h:168
DtAsyncLoadingFeatureSet< FS >::FeatureSet FeatureSet
Definition: asyncLoadingFeatureSet.h:170

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)