14 #ifndef OSGDB_DATABASEPAGER
15 #define OSGDB_DATABASEPAGER 1
17 #include <osg/NodeVisitor>
19 #include <osg/PagedLOD>
20 #include <osg/Drawable>
21 #include <osg/GraphicsThread>
22 #include <osg/FrameStamp>
23 #include <osg/ObserverNodePath>
24 #include <osg/observer_ptr>
26 #include <OpenThreads/Thread>
27 #include <OpenThreads/Mutex>
28 #include <OpenThreads/ScopedLock>
29 #include <OpenThreads/Condition>
31 #include <osgUtil/IncrementalCompileOperation>
33 #include <osgDB/SharedStateManager>
34 #include <osgDB/ReaderWriter>
35 #include <osgDB/Options>
59 virtual const char*
className()
const {
return "DatabasePager"; }
73 virtual void requestNodeFile(
const std::string& fileName,
osg::NodePath& nodePath,
84 virtual bool isRunning()
const;
104 void setName(
const std::string& name) { _name = name; }
105 const std::string&
getName()
const {
return _name; }
107 void setDone(
bool done) { _done.exchange(done?1:0); }
113 virtual int cancel();
129 void setUpThreads(
unsigned int totalNumThreads=2,
unsigned int numHttpThreads=1);
140 void setDatabasePagerThreadPause(
bool pause);
160 virtual void signalEndFrame();
166 virtual void registerPagedLODs(
osg::Node* subgraph,
unsigned int frameNumber = 0);
234 void setMaxAnisotropyPolicy(
bool changeAnisotropy,
float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; }
237 void getMaxAnisotropyPolicy(
bool& changeAnisotropy,
float& valueAnisotropy)
const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; }
241 bool requiresUpdateSceneGraph()
const;
248 unsigned int getFileRequestListSize()
const {
return static_cast<unsigned int>(_fileRequestQueue->size() + _httpRequestQueue->size()); }
257 bool getRequestsInProgress()
const;
266 double getAverageTimeToMergeTiles()
const {
return (_numTilesMerges > 0) ? _totalTimeToMergeTiles/
static_cast<double>(_numTilesMerges) : 0; }
274 class ExpirePagedLODsVisitor;
276 typedef std::list< osg::ref_ptr<osg::Object> >
ObjectList;
281 virtual void clear() = 0;
282 virtual unsigned int size() = 0;
283 virtual void removeExpiredChildren(
int numberChildrenToRemove,
double expiryTime,
unsigned int expiryFrame, ObjectList& childrenRemoved,
bool visitActive) = 0;
305 osg::Referenced(true),
307 _frameNumberFirstRequest(0),
308 _timestampFirstRequest(0.0),
309 _priorityFirstRequest(0.f),
310 _frameNumberLastRequest(0),
311 _timestampLastRequest(0.0),
312 _priorityLastRequest(0.0f),
319 bool valid()
const {
return _valid; }
323 return _valid && (frameNumber - _frameNumberLastRequest <= 1);
362 bool pruneOldRequestsAndCheckIfEmpty();
376 void swap(RequestList& requestList);
398 virtual void updateBlock();
410 class FindCompileableGLObjectsVisitor;
411 friend class FindCompileableGLObjectsVisitor;
413 struct DatabasePagerCompileCompletedCallback;
414 friend struct DatabasePagerCompileCompletedCallback;
416 class FindPagedLODsVisitor;
417 friend class FindPagedLODsVisitor;
419 struct SortFileRequestFunctor;
420 friend struct SortFileRequestFunctor;
432 virtual void removeExpiredSubgraphs(
const osg::FrameStamp &frameStamp);
This class provides an object-oriented thread mutex interface.
void swap(MixinVector< ValueT > &left, MixinVector< ValueT > &right)
This class provides an atomic increment and decrement operation.
T * clone(const T *t, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
This class provides an object-oriented thread interface.
std::vector< ref_ptr< Node > > NodeList
std::vector< Node * > NodePath