14#ifndef OSGDB_DATABASEPAGER
15#define OSGDB_DATABASEPAGER 1
26#include <OpenThreads/Thread>
27#include <OpenThreads/Mutex>
28#include <OpenThreads/ScopedLock>
29#include <OpenThreads/Condition>
59 virtual const char*
className()
const {
return "DatabasePager"; }
133 void setUpThreads(
unsigned int totalNumThreads=2,
unsigned int numHttpThreads=1);
281 class ExpirePagedLODsVisitor;
289 virtual unsigned int size() = 0;
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
std::vector< ref_ptr< Node > > NodeList
Definition Group:22
std::vector< Node * > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant.
Definition Node:47
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
Base class for all internal nodes in the scene graph.
Definition Node:72
Callback for managing database paging, such as generated by PagedLOD nodes.
Definition NodeVisitor:364
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
double _maximumTimeToMergeTile
Definition DatabasePager:482
virtual void removeExpiredSubgraphs(const osg::FrameStamp &frameStamp)
Iterate through the active PagedLOD nodes children removing children which haven't been visited since...
double getMaximumTimeToMergeTile() const
Get the maximum time between the first request for a tile to be loaded and the time of its merge into...
Definition DatabasePager:270
bool _acceptNewRequests
Definition DatabasePager:448
OpenThreads::Mutex _dr_mutex
Definition DatabasePager:431
bool requiresUpdateSceneGraph() const
Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(d...
bool getAcceptNewDatabaseRequests() const
Get whether new database request calls are accepted or ignored.
Definition DatabasePager:153
virtual void setProcessorAffinity(const OpenThreads::Affinity &affinity)
DatabaseThread * getDatabaseThread(unsigned int i)
Definition DatabasePager:137
void resetStats()
Reset the Stats variables.
osg::ref_ptr< RequestQueue > _dataToCompileList
Definition DatabasePager:459
bool requiresRedraw() const
Return true if there are GL objects that need to be compiled by a draw traversal.
const osg::Object * getMarkerObject() const
Definition DatabasePager:298
osg::Object * getMarkerObject()
Definition DatabasePager:297
std::vector< osg::ref_ptr< DatabaseThread > > DatabaseThreadList
Definition DatabasePager:395
friend struct SortFileRequestFunctor
Definition DatabasePager:427
void setDrawablePolicy(DrawablePolicy policy)
Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array...
Definition DatabasePager:217
osg::ref_ptr< ReadQueue > _httpRequestQueue
Definition DatabasePager:458
double _minimumTimeToMergeTile
Definition DatabasePager:481
osg::ref_ptr< osgUtil::IncrementalCompileOperation > _incrementalCompileOperation
Definition DatabasePager:478
int _numFramesActive
Definition DatabasePager:453
int getNumFramesActive() const
Get the number of frames that are currently active.
Definition DatabasePager:156
int setSchedulePriority(OpenThreads::Thread::ThreadPriority priority)
Set the priority of the database pager thread(s).
DrawablePolicy getDrawablePolicy() const
Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array...
Definition DatabasePager:220
std::list< osg::ref_ptr< osg::Object > > ObjectList
Definition DatabasePager:283
unsigned int getTargetMaximumNumberOfPageLOD() const
Get the target maximum number of PagedLOD to maintain in memory.
Definition DatabasePager:199
void setDoPreCompile(bool flag)
Set whether the database pager should pre compile OpenGL objects before allowing them to be merged in...
Definition DatabasePager:185
OpenThreads::Affinity & getProcessorAffinity()
Definition DatabasePager:130
virtual void requestNodeFile(const std::string &fileName, osg::NodePath &nodePath, float priority, const osg::FrameStamp *framestamp, osg::ref_ptr< osg::Referenced > &databaseRequest, const osg::Referenced *options)
Add a request to load a node file to end the database request list.
unsigned int getDataToMergeListSize() const
Report how many items are in the _dataToMergeList queue.
Definition DatabasePager:261
unsigned int getFileRequestListSize() const
Report how many items are in the _fileRequestList queue.
Definition DatabasePager:255
osg::ref_ptr< PagedLODList > _activePagedLODList
Definition DatabasePager:473
virtual void clear()
Clear all internally cached structures.
unsigned int getNumDatabaseThreads() const
Definition DatabasePager:141
double getAverageTimeToMergeTiles() const
Get the average time between the first request for a tile to be loaded and the time of its merge into...
Definition DatabasePager:273
virtual void updateSceneGraph(const osg::FrameStamp &frameStamp)
Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSc...
void setTargetMaximumNumberOfPageLOD(unsigned int target)
Set the target maximum number of PagedLOD to maintain in memory.
Definition DatabasePager:196
void setDatabasePagerThreadPause(bool pause)
Set whether the database pager thread should be paused or not.
OpenThreads::Affinity _affinity
Definition DatabasePager:445
void getUnrefImageDataAfterApplyPolicy(bool &changeAutoUnRef, bool &valueAutoUnRef) const
Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value...
Definition DatabasePager:234
const OpenThreads::Affinity & getProcessorAffinity() const
Definition DatabasePager:131
static DatabasePager * create()
create a DatabasePager by cloning DatabasePager::prototype().
void compileCompleted(DatabaseRequest *databaseRequest)
void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef)
Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value...
Definition DatabasePager:231
virtual int cancel()
Cancel the database pager thread(s).
std::vector< osg::ref_ptr< osg::Drawable > > DrawableList
Definition DatabasePager:279
DatabasePager(const DatabasePager &rhs)
bool _doPreCompile
Definition DatabasePager:477
OpenThreads::Thread::ThreadPriority ThreadPriority
Definition DatabasePager:53
friend class FindCompileableGLObjectsVisitor
Definition DatabasePager:418
osgUtil::IncrementalCompileOperation * getIncrementalCompileOperation()
Get the incremental compile operation.
Definition DatabasePager:178
bool _assignPBOToImages
Definition DatabasePager:464
osg::ref_ptr< ReadQueue > _fileRequestQueue
Definition DatabasePager:457
void setUpThreads(unsigned int totalNumThreads=2, unsigned int numHttpThreads=1)
friend class FindPagedLODsVisitor
Definition DatabasePager:424
friend struct DatabasePagerCompileCompletedCallback
Definition DatabasePager:421
bool getApplyPBOToImages() const
Get whether newly loaded textures should have a PixelBufferObject assigned to them.
Definition DatabasePager:227
void getMaxAnisotropyPolicy(bool &changeAnisotropy, float &valueAnisotropy) const
Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.
Definition DatabasePager:241
virtual bool isRunning() const
bool _changeAnisotropy
Definition DatabasePager:467
std::set< osg::ref_ptr< osg::StateSet > > StateSetList
Definition DatabasePager:278
virtual const char * className() const
Definition DatabasePager:59
bool getDeleteRemovedSubgraphsInDatabaseThread() const
Get whether the removed subgraphs should be deleted in the database thread or not.
Definition DatabasePager:206
unsigned int _numTilesMerges
Definition DatabasePager:484
virtual void registerPagedLODs(osg::Node *subgraph, unsigned int frameNumber=0)
Find all PagedLOD nodes in a subgraph and register them with the DatabasePager so it can keep track o...
const DatabaseThread * getDatabaseThread(unsigned int i) const
Definition DatabasePager:139
bool _databasePagerThreadPaused
Definition DatabasePager:449
bool _changeAutoUnRef
Definition DatabasePager:465
double getMinimumTimeToMergeTile() const
Get the minimum time between the first request for a tile to be loaded and the time of its merge into...
Definition DatabasePager:267
void setDeleteRemovedSubgraphsInDatabaseThread(bool flag)
Set whether the removed subgraphs should be deleted in the database thread or not.
Definition DatabasePager:203
bool _startThreadCalled
Definition DatabasePager:432
unsigned int getDataToCompileListSize() const
Report how many items are in the _dataToCompileList queue.
Definition DatabasePager:258
bool _deleteRemovedSubgraphsInDatabaseThread
Definition DatabasePager:470
bool _done
Definition DatabasePager:447
DatabaseThreadList _databaseThreads
Definition DatabasePager:451
virtual unsigned int addDatabaseThread(DatabaseThread::Mode mode, const std::string &name)
void setApplyPBOToImages(bool assignPBOToImages)
Set whether newly loaded textures should have a PixelBufferObject assigned to them to aid download to...
Definition DatabasePager:224
virtual DatabasePager * clone() const
Create a shallow copy on the DatabasePager.
Definition DatabasePager:62
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
Set the incremental compile operation.
virtual void signalBeginFrame(const osg::FrameStamp *framestamp)
Signal the database thread that the update, cull and draw has begun for a new frame.
bool getRequestsInProgress() const
Report whether any requests are in the pager.
static osg::ref_ptr< DatabasePager > & prototype()
get the prototype singleton used by DatabasePager::create().
unsigned int _targetMaximumNumberOfPageLOD
Definition DatabasePager:475
osg::ref_ptr< RequestQueue > _dataToMergeList
Definition DatabasePager:460
OpenThreads::Atomic _frameNumber
Definition DatabasePager:455
osg::ref_ptr< osg::Object > _markerObject
Definition DatabasePager:486
void addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp)
Add the loaded data to the scene graph.
DrawablePolicy
Definition DatabasePager:209
@ USE_VERTEX_BUFFER_OBJECTS
Definition DatabasePager:212
@ USE_VERTEX_ARRAYS
Definition DatabasePager:213
@ DO_NOT_MODIFY_DRAWABLE_SETTINGS
Definition DatabasePager:210
@ USE_DISPLAY_LISTS
Definition DatabasePager:211
void setAcceptNewDatabaseRequests(bool acceptNewRequests)
Set whether new database request calls are accepted or ignored.
Definition DatabasePager:150
DrawablePolicy _drawablePolicy
Definition DatabasePager:462
double _totalTimeToMergeTiles
Definition DatabasePager:483
bool getDatabasePagerThreadPause() const
Get whether the database pager thread should is paused or not.
Definition DatabasePager:147
bool _valueAutoUnRef
Definition DatabasePager:466
float _valueAnisotropy
Definition DatabasePager:468
OpenThreads::Mutex _run_mutex
Definition DatabasePager:430
OpenThreads::Mutex _numFramesActiveMutex
Definition DatabasePager:454
void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy)
Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.
Definition DatabasePager:238
virtual void signalEndFrame()
Signal the database thread that the update, cull and draw dispatch has completed.
void setMarkerObject(osg::Object *mo)
Definition DatabasePager:296
bool getDoPreCompile() const
Get whether the database pager should pre compile OpenGL objects before allowing them to be merged in...
Definition DatabasePager:189
Definition DatabasePager:90
void setActive(bool active)
Definition DatabasePager:110
void setDone(bool done)
Definition DatabasePager:107
std::string _name
Definition DatabasePager:125
const std::string & getName() const
Definition DatabasePager:105
virtual ~DatabaseThread()
bool getActive() const
Definition DatabasePager:111
DatabasePager * _pager
Definition DatabasePager:123
OpenThreads::Atomic _done
Definition DatabasePager:121
void setName(const std::string &name)
Definition DatabasePager:104
Mode _mode
Definition DatabasePager:124
bool getDone() const
Definition DatabasePager:108
DatabaseThread(const DatabaseThread &dt, DatabasePager *pager)
volatile bool _active
Definition DatabasePager:122
DatabaseThread(DatabasePager *pager, Mode mode, const std::string &name)
Mode
Definition DatabasePager:94
@ HANDLE_NON_HTTP
Definition DatabasePager:96
@ HANDLE_ALL_REQUESTS
Definition DatabasePager:95
@ HANDLE_ONLY_HTTP
Definition DatabasePager:97
Definition DatabasePager:286
virtual unsigned int size()=0
virtual void removeExpiredChildren(int numberChildrenToRemove, double expiryTime, unsigned int expiryFrame, ObjectList &childrenRemoved, bool visitActive)=0
virtual void insertPagedLOD(const osg::observer_ptr< osg::PagedLOD > &plod)=0
virtual bool containsPagedLOD(const osg::observer_ptr< osg::PagedLOD > &plod) const =0
virtual PagedLODList * clone()=0
virtual void removeNodes(osg::NodeList &nodesToRemove)=0
Definition DatabasePager:310
float _priorityFirstRequest
Definition DatabasePager:337
unsigned int _frameNumberFirstRequest
Definition DatabasePager:335
bool isRequestCurrent(int frameNumber) const
Definition DatabasePager:328
unsigned int _numOfRequests
Definition DatabasePager:341
osg::ref_ptr< osg::Node > _loadedModel
Definition DatabasePager:346
osg::observer_ptr< osg::Group > _group
Definition DatabasePager:344
bool _valid
Definition DatabasePager:333
double _timestampFirstRequest
Definition DatabasePager:336
osg::ref_ptr< Options > _loadOptions
Definition DatabasePager:347
osg::observer_ptr< osgUtil::IncrementalCompileOperation::CompileSet > _compileSet
Definition DatabasePager:350
osg::ref_ptr< ObjectCache > _objectCache
Definition DatabasePager:348
double _timestampLastRequest
Definition DatabasePager:339
unsigned int _frameNumberLastRequest
Definition DatabasePager:338
bool valid() const
Definition DatabasePager:326
bool _groupExpired
Definition DatabasePager:351
float _priorityLastRequest
Definition DatabasePager:340
osg::observer_ptr< osg::Node > _terrain
Definition DatabasePager:343
DatabaseRequest()
Definition DatabasePager:311
std::string _fileName
Definition DatabasePager:334
Definition DatabasePager:356
bool pruneOldRequestsAndCheckIfEmpty()
prune all the old requests and then return true if requestList left empty
void add(DatabaseRequest *databaseRequest)
RequestQueue(DatabasePager *pager)
void invalidate(DatabaseRequest *dr)
void swap(RequestList &requestList)
void remove(DatabaseRequest *databaseRequest)
OpenThreads::Mutex _requestMutex
Definition DatabasePager:387
RequestList _requestList
Definition DatabasePager:386
void takeFirst(osg::ref_ptr< DatabaseRequest > &databaseRequest)
std::list< osg::ref_ptr< DatabaseRequest > > RequestList
Definition DatabasePager:382
DatabasePager * _pager
Definition DatabasePager:385
unsigned int _frameNumberLastPruned
Definition DatabasePager:388
virtual void updateBlock()
Definition DatabasePager:371
void addNoLock(DatabaseRequest *databaseRequest)
void block()
Definition DatabasePager:401
ReadQueue(DatabasePager *pager, const std::string &name)
std::string _name
Definition DatabasePager:410
ObjectList _childrenToDeleteList
Definition DatabasePager:413
void release()
Definition DatabasePager:403
virtual void updateBlock()
OpenThreads::Mutex _childrenToDeleteListMutex
Definition DatabasePager:412
osg::ref_ptr< osg::RefBlock > _block
Definition DatabasePager:408
Definition IncrementalCompileOperation:56
#define OSGDB_EXPORT
Definition Export:39