VR-Forces 4.2 Class Documentation
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>
14 
15 #include <vrfutil/callbackQueue.h>
16 
17 #include <tbb/mutex.h>
18 #include <tbb/spin_mutex.h>
19 #include <tbb/tbb_thread.h>
20 #include <tbb/compat/condition_variable>
21 
22 namespace MAKVRinTerra
23 {
27  template <typename FS>
29  : virtual public FS
31  , public boost::enable_shared_from_this<DtAsyncLoadingFeatureSet<FS> >
32  {
33  public:
35  typedef boost::shared_ptr<DtAsyncLoadingFeatureSet> Ptr;
36 
38  typedef boost::weak_ptr<DtAsyncLoadingFeatureSet> WPtr;
39 
40  typedef FS FeatureSet;
41  typedef typename FS::Feature Feature;
42  typedef typename FeatureSet::ForEachFunction ForEachFunction;
43 
44  class Empty;
45 
49 
50  static bool Run(const Ptr&);
51  static bool Run(WPtr);
53 
55  virtual void start() = 0;
56 
57  std::string label() const;
58  void forEachFeature(ForEachFunction, DtWaitType) const;
59  void forEachFeatureParallel(ForEachFunction, DtWaitType) const;
60  FeatureSet* filter(const DtQuery&, DtLoadType) const;
61  FeatureSet* clone() const;
62  bool loaded(double) const;
63  unsigned numberOfFeatures() const;
64  bool empty() const;
65 
66  unsigned size() const;
67  boost::shared_ptr<DtUnusedFeatureTileTracker::Trackable> getPtr();
68 
69  void load();
70  void unload();
71  bool loading() const;
72  bool loaded() const;
73 
74  protected:
75  typedef tbb::spin_rw_mutex RWMutex;
76  typedef tbb::mutex Mutex;
77  typedef tbb::interface5::condition_variable ConditionVariable;
78  typedef tbb::interface5::unique_lock<Mutex> ScopedLock;
79 
80  struct Caller;
81 
83  virtual bool run(const Ptr&);
84 
88  virtual FeatureSet* createFeatureSet(FeatureSet* fs) const;
89 
90  explicit DtAsyncLoadingFeatureSet(
92 
93  mutable RWMutex myRWMutex;
94  mutable Mutex myMutex;
96 
97  std::auto_ptr<FeatureSet> myInputFeatureSet;
99  std::auto_ptr<FeatureSet> myFeatureSet;
102  };
103 
104  template <typename FS>
106  : public DtAsyncLoadingFeatureSet<FS>
107  {
108  public:
109  explicit Empty(DtUnusedFeatureTileTracker::Ptr);
110 
111  void start();
112 
113  void load();
114  void unload();
115  bool loading() const;
116 
117  protected:
118  };
119 
120  template <typename FS>
122  : public DtAsyncLoadingFeatureSet<FS>
123  {
124  public:
125  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> Ptr;
126  typedef boost::shared_ptr<DtQueueLoadingFeatureSet> WPtr;
130  typedef typename FeatureSet::ForEachFunction ForEachFunction;
131 
133 
135  void start();
136 
137  FS* createFeatureSet(FS* fs) const;
138 
140  FeatureSet* input, DtQuery query,
141  boost::weak_ptr<Queue> queue,
143 
144  boost::weak_ptr<Queue> myQueue;
145  };
146 }

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)