VR-Forces 4.2 Class Documentation
featureContext.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 
14 #include <features/featureSet.h>
15 #include <features/feature.h>
16 #include <features/pathFeature.h>
17 #include <features/pathFinder.h>
20 
23 
24 #include <boost/scoped_ptr.hpp>
25 #include <boost/ptr_container/ptr_map.hpp>
26 
27 #include <tbb/mutex.h>
28 
29 #include <map>
30 #include <string>
31 
32 class DtVectorNetwork;
33 
34 namespace osg
35 {
36  template<typename T>
37  class ref_ptr;
38 }
39 
40 namespace osgEarth
41 {
42  class Map;
43 }
44 
45 namespace MAKVRinTerra
46 {
47  class DtSharedMemoryFeaturesDebugDrawer;
48  class DtFeatureContext;
49  class DtFeaturesDebugger;
50  class DtUnusedFeatureTileTracker;
51 
53  {
54  public:
56  typedef boost::function<DtFeatureSet* (std::string)> FeatureSetCreatorFcn;
57 
60 
64  DtFeatureLoader(boost::shared_ptr<DtTerrainInterfaceConfig> config, DtConsoleCommandManager* manager = 0);
65 
67  virtual ~DtFeatureLoader();
68 
73  static void AddFeatureSetCreator(std::string extension, FeatureSetCreatorFcn factory);
74 
77  static DtFeatureSet* CreateFeatureSetFromFile(std::string file);
78 
83  static DtFeatureSet* ConfigureAttribute(
84  DtFeatureSet* set, std::string attribute, std::string value);
85 
86  static std::auto_ptr<DtFeatureSet> ConfigureAttribute(
87  std::auto_ptr<DtFeatureSet> set, std::string attribute, std::string value);
88 
93  virtual bool loadSrcSpecConfigFor(std::string sourceFile, std::string attribute);
94 
102  virtual bool loadConfig(std::string configFile, DtQuery schema);
103 
108  virtual std::auto_ptr<DtFeatureSet> addFeatureSource(std::string file, bool page=true);
109 
115  virtual std::auto_ptr<DtFeatureSet> addFeatureSource(
116  osg::ref_ptr<osgEarth::Map> map,
117  std::string earthfile=std::string(), bool page=true);
118 
123  virtual std::auto_ptr<DtFeatureSet> addFeatureSource(DtFeatureSet* fs, bool page=true);
124 
129  virtual std::auto_ptr<DtFeatureSet> addVectorNetworkFeatureSource(
130  DtVectorNetwork* network, std::string sourceFile);
131 
138  virtual std::auto_ptr<DtFeatureSet> addFeatureSource(
139  DtFeatureSet* fs, std::string source, bool page=true);
140 
145  void addToDebugger(DtFeatureSet* fs, bool draw = false, std::string label = std::string());
146 
148  boost::shared_ptr<DtAttributeConfigParser> parser() const;
149 
151  boost::shared_ptr<DtTerrainInterfaceConfig> config() const;
152 
154  boost::shared_ptr<DtUnusedFeatureTileTracker> tracker() const;
155 
157  boost::shared_ptr<DtFeaturesDebugger> debugger() const;
158 
160  boost::shared_ptr<LoadingQueue> loadingQueue() const;
161 
164  virtual DtFeatureContext* makeContext(const DtProj& proj);
165 
166  private:
170  struct Record
171  {
172  typedef boost::shared_ptr<Record> Ptr;
173  typedef std::vector<Ptr> Vector;
174 
175  std::auto_ptr<DtFeatureSet> featureSet;
176  bool page;
177 
178  Record(DtFeatureSet*, bool page);
179  };
180 
181  boost::shared_ptr<DtTerrainInterfaceConfig> myTerrainInterfaceConfig;
182  boost::shared_ptr<DtAttributeConfigParser> myParser;
183  boost::shared_ptr<DtUnusedFeatureTileTracker> myUnusedTracker;
184  boost::shared_ptr<DtFeaturesDebugger> myDebugger;
185 
187  boost::shared_ptr<LoadingQueue> myLoadingQueue;
188  };
189 
191  {
192  public:
199  DtFeatureSet* sourceFeatures,
200  DtFeatureSet* features,
201  const DtProj& proj,
202  DtFeatureLoader& loader);
203 
205  ~DtFeatureContext();
206 
208  void shutdown();
209 
214  std::auto_ptr<DtFeatureSet> features(
215  std::string queryName = std::string(),
216  bool readDirectly = false);
217 
220  std::auto_ptr<DtObstacleFeatureSet> obstacles(std::string type);
221 
224 
227  std::auto_ptr<DtObstacleFeatureSet> obstacles(ObstacleConfig cfg);
228 
230  std::auto_ptr<DtPathFeatureSet> paths(std::string type);
231 
233  DtPathFinder& pathFinder(std::string type);
234 
236  DtFeaturesDebugger& debugger();
237 
239  DtQuery findQuery(std::string name) const;
240 
242  DtProj::CPtr projection() const;
243 
247  void cleanUpPathFinders();
248 
249  private:
252 
254  boost::shared_ptr<DtTerrainInterfaceConfig> myTerrainInterfaceConfig;
255 
257  boost::scoped_ptr<DtFeatureSet> mySourceFeatures;
258 
260  boost::scoped_ptr<DtFeatureSet> myFeatures;
261 
263  typedef boost::ptr_map<std::string, DtFeatureSet> FeatureSetMap;
266  mutable tbb::mutex myFeatureSetMutex;
267  boost::shared_ptr<FeatureQueue> myFeatureLoadingQueue;
268 
270  typedef boost::ptr_map<ObstacleConfig, DtObstacleFeatureSet> ObstacleFeatureSetMap;
273  mutable tbb::mutex myObstaclesMutex;
274  boost::shared_ptr<ObstacleQueue> myObstacleLoadingQueue;
275 
277  typedef boost::ptr_map<std::string, DtPathFinder> PathFinderMap;
279  mutable tbb::mutex myPathFindersMutex;
280 
282  boost::shared_ptr<DtAttributeConfigParser> myAttributeParser;
283 
285  boost::shared_ptr<DtUnusedFeatureTileTracker> myUnusedTracker;
286 
288  boost::shared_ptr<DtFeaturesDebugger> myDebugger;
289  };
290 }

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)