OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cellpreloader.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_MWWORLD_CELLPRELOADER_H
2 #define OPENMW_MWWORLD_CELLPRELOADER_H
3 
4 #include <map>
5 #include <osg/ref_ptr>
7 
8 namespace Resource
9 {
10  class ResourceSystem;
11  class BulletShapeManager;
12 }
13 
14 namespace Terrain
15 {
16  class World;
17 }
18 
19 namespace MWWorld
20 {
21  class CellStore;
22 
24  {
25  public:
26  CellPreloader(Resource::ResourceSystem* resourceSystem, Resource::BulletShapeManager* bulletShapeManager, Terrain::World* terrain);
28 
31  void preload(MWWorld::CellStore* cell, double timestamp);
32 
33  void notifyLoaded(MWWorld::CellStore* cell);
34 
36  void updateCache(double timestamp);
37 
39  void setExpiryDelay(double expiryDelay);
40 
42  void setMinCacheSize(unsigned int num);
43 
45  void setMaxCacheSize(unsigned int num);
46 
48  void setPreloadInstances(bool preload);
49 
50  unsigned int getMaxCacheSize() const;
51 
52  void setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue);
53 
54  private:
58  osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
59  double mExpiryDelay;
60  unsigned int mMinCacheSize;
61  unsigned int mMaxCacheSize;
63 
64  struct PreloadEntry
65  {
66  PreloadEntry(double timestamp, osg::ref_ptr<SceneUtil::WorkItem> workItem)
67  : mTimeStamp(timestamp)
68  , mWorkItem(workItem)
69  {
70  }
72  : mTimeStamp(0.0)
73  {
74  }
75 
76  double mTimeStamp;
77  osg::ref_ptr<SceneUtil::WorkItem> mWorkItem;
78  };
79  typedef std::map<const MWWorld::CellStore*, PreloadEntry> PreloadMap;
80 
81  // Cells that are currently being preloaded, or have already finished preloading
83  };
84 
85 }
86 
87 #endif
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
void setExpiryDelay(double expiryDelay)
How long to keep a preloaded cell in cache after it's no longer requested.
Definition: cellpreloader.cpp:259
The basic interface for a terrain world. How the terrain chunks are paged and displayed is up to the ...
Definition: world.hpp:32
void setPreloadInstances(bool preload)
Enables the creation of instances in the preloading thread.
Definition: cellpreloader.cpp:274
unsigned int mMaxCacheSize
Definition: cellpreloader.hpp:61
void num(char i, bool last)
Definition: gen_iconv.cpp:12
CellPreloader(Resource::ResourceSystem *resourceSystem, Resource::BulletShapeManager *bulletShapeManager, Terrain::World *terrain)
Definition: cellpreloader.cpp:174
Resource::ResourceSystem * mResourceSystem
Definition: cellpreloader.hpp:55
Resource::BulletShapeManager * mBulletShapeManager
Definition: cellpreloader.hpp:56
Definition: cellpreloader.hpp:64
void preload(MWWorld::CellStore *cell, double timestamp)
Definition: cellpreloader.cpp:192
void setMinCacheSize(unsigned int num)
The minimum number of preloaded cells before unused cells get thrown out.
Definition: cellpreloader.cpp:264
PreloadEntry(double timestamp, osg::ref_ptr< SceneUtil::WorkItem > workItem)
Definition: cellpreloader.hpp:66
bool mPreloadInstances
Definition: cellpreloader.hpp:62
~CellPreloader()
Definition: cellpreloader.cpp:185
osg::ref_ptr< SceneUtil::WorkQueue > mWorkQueue
Definition: cellpreloader.hpp:58
std::map< const MWWorld::CellStore *, PreloadEntry > PreloadMap
Definition: cellpreloader.hpp:79
Mutable state of a cell.
Definition: cellstore.hpp:53
PreloadMap mPreloadCells
Definition: cellpreloader.hpp:82
void setMaxCacheSize(unsigned int num)
The maximum number of preloaded cells.
Definition: cellpreloader.cpp:269
unsigned int mMinCacheSize
Definition: cellpreloader.hpp:60
void setWorkQueue(osg::ref_ptr< SceneUtil::WorkQueue > workQueue)
Definition: cellpreloader.cpp:284
Terrain::World * mTerrain
Definition: cellpreloader.hpp:57
double mExpiryDelay
Definition: cellpreloader.hpp:59
double mTimeStamp
Definition: cellpreloader.hpp:76
void notifyLoaded(MWWorld::CellStore *cell)
Definition: cellpreloader.cpp:240
unsigned int getMaxCacheSize() const
Definition: cellpreloader.cpp:279
Definition: bulletshapemanager.hpp:25
void updateCache(double timestamp)
Removes preloaded cells that have not had a preload request for a while.
Definition: cellpreloader.cpp:245
osg::ref_ptr< SceneUtil::WorkItem > mWorkItem
Definition: cellpreloader.hpp:77
PreloadEntry()
Definition: cellpreloader.hpp:71
Definition: cellpreloader.hpp:23