OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
osgDB::DatabasePager Class Reference

#include <DatabasePager.h>

Inheritance diagram for osgDB::DatabasePager:
Inheritance graph
[legend]
Collaboration diagram for osgDB::DatabasePager:
Collaboration graph
[legend]

Classes

struct  DatabaseRequest
 
class  DatabaseThread
 
struct  PagedLODList
 
struct  ReadQueue
 
struct  RequestQueue
 

Public Types

enum  DrawablePolicy { DO_NOT_MODIFY_DRAWABLE_SETTINGS, USE_DISPLAY_LISTS, USE_VERTEX_BUFFER_OBJECTS, USE_VERTEX_ARRAYS }
 
typedef
OpenThreads::Thread::ThreadPriority 
ThreadPriority
 
typedef std::set< osg::ref_ptr
< osg::StateSet > > 
StateSetList
 
typedef std::vector
< osg::ref_ptr< osg::Drawable > > 
DrawableList
 
typedef std::list
< osg::ref_ptr< osg::Object > > 
ObjectList
 

Public Member Functions

 DatabasePager ()
 
 DatabasePager (const DatabasePager &rhs)
 
virtual const char * className () const
 
virtual DatabasePagerclone () const
 
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)
 
int setSchedulePriority (OpenThreads::Thread::ThreadPriority priority)
 
virtual int cancel ()
 
virtual bool isRunning () const
 
virtual void clear ()
 
void setUpThreads (unsigned int totalNumThreads=2, unsigned int numHttpThreads=1)
 
virtual unsigned int addDatabaseThread (DatabaseThread::Mode mode, const std::string &name)
 
DatabaseThreadgetDatabaseThread (unsigned int i)
 
const DatabaseThreadgetDatabaseThread (unsigned int i) const
 
unsigned int getNumDatabaseThreads () const
 
void setDatabasePagerThreadPause (bool pause)
 
bool getDatabasePagerThreadPause () const
 
void setAcceptNewDatabaseRequests (bool acceptNewRequests)
 
bool getAcceptNewDatabaseRequests () const
 
int getNumFramesActive () const
 
virtual void signalBeginFrame (const osg::FrameStamp *framestamp)
 
virtual void signalEndFrame ()
 
virtual void registerPagedLODs (osg::Node *subgraph, unsigned int frameNumber=0)
 
void setIncrementalCompileOperation (osgUtil::IncrementalCompileOperation *ico)
 
osgUtil::IncrementalCompileOperationgetIncrementalCompileOperation ()
 
void setDoPreCompile (bool flag)
 
bool getDoPreCompile () const
 
void setTargetMaximumNumberOfPageLOD (unsigned int target)
 
unsigned int getTargetMaximumNumberOfPageLOD () const
 
void setDeleteRemovedSubgraphsInDatabaseThread (bool flag)
 
bool getDeleteRemovedSubgraphsInDatabaseThread () const
 
void setDrawablePolicy (DrawablePolicy policy)
 
DrawablePolicy getDrawablePolicy () const
 
void setApplyPBOToImages (bool assignPBOToImages)
 
bool getApplyPBOToImages () const
 
void setUnrefImageDataAfterApplyPolicy (bool changeAutoUnRef, bool valueAutoUnRef)
 
void getUnrefImageDataAfterApplyPolicy (bool &changeAutoUnRef, bool &valueAutoUnRef) const
 
void setMaxAnisotropyPolicy (bool changeAnisotropy, float valueAnisotropy)
 
void getMaxAnisotropyPolicy (bool &changeAnisotropy, float &valueAnisotropy) const
 
bool requiresUpdateSceneGraph () const
 
virtual void updateSceneGraph (const osg::FrameStamp &frameStamp)
 
unsigned int getFileRequestListSize () const
 
unsigned int getDataToCompileListSize () const
 
unsigned int getDataToMergeListSize () const
 
bool getRequestsInProgress () const
 
double getMinimumTimeToMergeTile () const
 
double getMaximumTimeToMergeTile () const
 
double getAverageTimeToMergeTiles () const
 
void resetStats ()
 
void setMarkerObject (osg::Object *mo)
 
osg::ObjectgetMarkerObject ()
 
const osg::ObjectgetMarkerObject () const
 
- Public Member Functions inherited from osg::NodeVisitor::DatabaseRequestHandler
 DatabaseRequestHandler ()
 
- Public Member Functions inherited from osg::Referenced
 Referenced ()
 
 Referenced (bool threadSafeRefUnref)
 
 Referenced (const Referenced &)
 
Referencedoperator= (const Referenced &)
 
virtual void setThreadSafeRefUnref (bool threadSafe)
 
bool getThreadSafeRefUnref () const
 
OpenThreads::MutexgetRefMutex () const
 
int ref () const
 
int unref () const
 
int unref_nodelete () const
 
int referenceCount () const
 
ObserverSetgetObserverSet () const
 
ObserverSetgetOrCreateObserverSet () const
 
void addObserver (Observer *observer) const
 
void removeObserver (Observer *observer) const
 

Static Public Member Functions

static osg::ref_ptr
< DatabasePager > & 
prototype ()
 
static DatabasePagercreate ()
 
- Static Public Member Functions inherited from osg::Referenced
static OpenThreads::MutexgetGlobalReferencedMutex ()
 
static void setThreadSafeReferenceCounting (bool enableThreadSafeReferenceCounting)
 
static bool getThreadSafeReferenceCounting ()
 
static void setDeleteHandler (DeleteHandler *handler)
 
static DeleteHandlergetDeleteHandler ()
 

Protected Types

typedef std::vector
< osg::ref_ptr< DatabaseThread > > 
DatabaseThreadList
 

Protected Member Functions

virtual ~DatabasePager ()
 
void compileCompleted (DatabaseRequest *databaseRequest)
 
virtual void removeExpiredSubgraphs (const osg::FrameStamp &frameStamp)
 
void addLoadedDataToSceneGraph (const osg::FrameStamp &frameStamp)
 
- Protected Member Functions inherited from osg::NodeVisitor::DatabaseRequestHandler
virtual ~DatabaseRequestHandler ()
 
- Protected Member Functions inherited from osg::Referenced
virtual ~Referenced ()
 
void signalObserversAndDelete (bool signalDelete, bool doDelete) const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

OpenThreads::Mutex _run_mutex
 
OpenThreads::Mutex _dr_mutex
 
bool _startThreadCalled
 
bool _done
 
bool _acceptNewRequests
 
bool _databasePagerThreadPaused
 
DatabaseThreadList _databaseThreads
 
int _numFramesActive
 
OpenThreads::Mutex _numFramesActiveMutex
 
OpenThreads::Atomic _frameNumber
 
osg::ref_ptr< ReadQueue_fileRequestQueue
 
osg::ref_ptr< ReadQueue_httpRequestQueue
 
osg::ref_ptr< RequestQueue_dataToCompileList
 
osg::ref_ptr< RequestQueue_dataToMergeList
 
DrawablePolicy _drawablePolicy
 
bool _assignPBOToImages
 
bool _changeAutoUnRef
 
bool _valueAutoUnRef
 
bool _changeAnisotropy
 
float _valueAnisotropy
 
bool _deleteRemovedSubgraphsInDatabaseThread
 
osg::ref_ptr< PagedLODList_activePagedLODList
 
unsigned int _targetMaximumNumberOfPageLOD
 
bool _doPreCompile
 
osg::ref_ptr
< osgUtil::IncrementalCompileOperation
_incrementalCompileOperation
 
double _minimumTimeToMergeTile
 
double _maximumTimeToMergeTile
 
double _totalTimeToMergeTiles
 
unsigned int _numTilesMerges
 
osg::ref_ptr< osg::Object_markerObject
 
- Protected Attributes inherited from osg::Referenced
OpenThreads::AtomicPtr _observerSet
 
OpenThreads::Atomic _refCount
 

Friends

class DatabaseThread
 
struct DatabaseRequest
 
class FindCompileableGLObjectsVisitor
 
struct DatabasePagerCompileCompletedCallback
 
class FindPagedLODsVisitor
 
struct SortFileRequestFunctor
 

Detailed Description

Database paging class which manages the loading of files in a background thread, and synchronizing of loaded models with the main scene graph.

Definition at line 49 of file DatabasePager.h.

Member Typedef Documentation

Definition at line 388 of file DatabasePager.h.

Definition at line 272 of file DatabasePager.h.

Definition at line 274 of file DatabasePager.h.

Definition at line 271 of file DatabasePager.h.

Definition at line 53 of file DatabasePager.h.

Member Enumeration Documentation

Enumerator
DO_NOT_MODIFY_DRAWABLE_SETTINGS 
USE_DISPLAY_LISTS 
USE_VERTEX_BUFFER_OBJECTS 
USE_VERTEX_ARRAYS 

Definition at line 204 of file DatabasePager.h.

Constructor & Destructor Documentation

osgDB::DatabasePager::DatabasePager ( )
osgDB::DatabasePager::DatabasePager ( const DatabasePager rhs)
virtual osgDB::DatabasePager::~DatabasePager ( )
protectedvirtual

Member Function Documentation

virtual unsigned int osgDB::DatabasePager::addDatabaseThread ( DatabaseThread::Mode  mode,
const std::string &  name 
)
virtual
void osgDB::DatabasePager::addLoadedDataToSceneGraph ( const osg::FrameStamp frameStamp)
protected

Add the loaded data to the scene graph.

virtual int osgDB::DatabasePager::cancel ( )
virtual

Cancel the database pager thread(s).

virtual const char* osgDB::DatabasePager::className ( ) const
inlinevirtual

Definition at line 59 of file DatabasePager.h.

virtual void osgDB::DatabasePager::clear ( )
virtual

Clear all internally cached structures.

virtual DatabasePager* osgDB::DatabasePager::clone ( ) const
inlinevirtual

Create a shallow copy on the DatabasePager.

Definition at line 62 of file DatabasePager.h.

void osgDB::DatabasePager::compileCompleted ( DatabaseRequest databaseRequest)
protected
static DatabasePager* osgDB::DatabasePager::create ( )
static
bool osgDB::DatabasePager::getAcceptNewDatabaseRequests ( ) const
inline

Get whether new database request calls are accepted or ignored.

Definition at line 149 of file DatabasePager.h.

bool osgDB::DatabasePager::getApplyPBOToImages ( ) const
inline

Get whether newly loaded textures should have a PixelBufferObject assigned to them..

Definition at line 223 of file DatabasePager.h.

double osgDB::DatabasePager::getAverageTimeToMergeTiles ( ) const
inline

Get the average time between the first request for a tile to be loaded and the time of its merge into the main scene graph.

Definition at line 266 of file DatabasePager.h.

bool osgDB::DatabasePager::getDatabasePagerThreadPause ( ) const
inline

Get whether the database pager thread should is paused or not.

Definition at line 143 of file DatabasePager.h.

DatabaseThread* osgDB::DatabasePager::getDatabaseThread ( unsigned int  i)
inline

Definition at line 133 of file DatabasePager.h.

const DatabaseThread* osgDB::DatabasePager::getDatabaseThread ( unsigned int  i) const
inline

Definition at line 135 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::getDataToCompileListSize ( ) const
inline

Report how many items are in the _dataToCompileList queue

Definition at line 251 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::getDataToMergeListSize ( ) const
inline

Report how many items are in the _dataToMergeList queue

Definition at line 254 of file DatabasePager.h.

bool osgDB::DatabasePager::getDeleteRemovedSubgraphsInDatabaseThread ( ) const
inline

Get whether the removed subgraphs should be deleted in the database thread or not.

Definition at line 202 of file DatabasePager.h.

bool osgDB::DatabasePager::getDoPreCompile ( ) const
inline

Get whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph.

Definition at line 185 of file DatabasePager.h.

DrawablePolicy osgDB::DatabasePager::getDrawablePolicy ( ) const
inline

Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.

Definition at line 216 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::getFileRequestListSize ( ) const
inline

Report how many items are in the _fileRequestList queue

Definition at line 248 of file DatabasePager.h.

osgUtil::IncrementalCompileOperation* osgDB::DatabasePager::getIncrementalCompileOperation ( )
inline

Get the incremental compile operation.

Definition at line 174 of file DatabasePager.h.

osg::Object* osgDB::DatabasePager::getMarkerObject ( )
inline

Definition at line 290 of file DatabasePager.h.

const osg::Object* osgDB::DatabasePager::getMarkerObject ( ) const
inline

Definition at line 291 of file DatabasePager.h.

void osgDB::DatabasePager::getMaxAnisotropyPolicy ( bool &  changeAnisotropy,
float &  valueAnisotropy 
) const
inline

Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.

Definition at line 237 of file DatabasePager.h.

double osgDB::DatabasePager::getMaximumTimeToMergeTile ( ) const
inline

Get the maximum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.

Definition at line 263 of file DatabasePager.h.

double osgDB::DatabasePager::getMinimumTimeToMergeTile ( ) const
inline

Get the minimum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.

Definition at line 260 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::getNumDatabaseThreads ( ) const
inline

Definition at line 137 of file DatabasePager.h.

int osgDB::DatabasePager::getNumFramesActive ( ) const
inline

Get the number of frames that are currently active.

Definition at line 152 of file DatabasePager.h.

bool osgDB::DatabasePager::getRequestsInProgress ( ) const

Report whether any requests are in the pager.

unsigned int osgDB::DatabasePager::getTargetMaximumNumberOfPageLOD ( ) const
inline

Get the target maximum number of PagedLOD to maintain in memory.

Definition at line 195 of file DatabasePager.h.

void osgDB::DatabasePager::getUnrefImageDataAfterApplyPolicy ( bool &  changeAutoUnRef,
bool &  valueAutoUnRef 
) const
inline

Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.

Definition at line 230 of file DatabasePager.h.

virtual bool osgDB::DatabasePager::isRunning ( ) const
virtual
static osg::ref_ptr<DatabasePager>& osgDB::DatabasePager::prototype ( )
static

get the prototype singleton used by DatabasePager::create().

virtual void osgDB::DatabasePager::registerPagedLODs ( osg::Node subgraph,
unsigned int  frameNumber = 0 
)
virtual

Find all PagedLOD nodes in a subgraph and register them with the DatabasePager so it can keep track of expired nodes. note, should be only be called from the update thread.

virtual void osgDB::DatabasePager::removeExpiredSubgraphs ( const osg::FrameStamp frameStamp)
protectedvirtual

Iterate through the active PagedLOD nodes children removing children which havn't been visited since specified expiryTime. note, should be only be called from the update thread.

virtual void osgDB::DatabasePager::requestNodeFile ( const std::string &  fileName,
osg::NodePath nodePath,
float  priority,
const osg::FrameStamp framestamp,
osg::ref_ptr< osg::Referenced > &  databaseRequest,
const osg::Referenced options 
)
virtual

Add a request to load a node file to end the database request list.

Implements osg::NodeVisitor::DatabaseRequestHandler.

bool osgDB::DatabasePager::requiresUpdateSceneGraph ( ) const

Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double).

void osgDB::DatabasePager::resetStats ( )

Reset the Stats variables.

void osgDB::DatabasePager::setAcceptNewDatabaseRequests ( bool  acceptNewRequests)
inline

Set whether new database request calls are accepted or ignored.

Definition at line 146 of file DatabasePager.h.

void osgDB::DatabasePager::setApplyPBOToImages ( bool  assignPBOToImages)
inline

Set whether newly loaded textures should have a PixelBufferObject assigned to them to aid download to the GPU.

Definition at line 220 of file DatabasePager.h.

void osgDB::DatabasePager::setDatabasePagerThreadPause ( bool  pause)

Set whether the database pager thread should be paused or not.

void osgDB::DatabasePager::setDeleteRemovedSubgraphsInDatabaseThread ( bool  flag)
inline

Set whether the removed subgraphs should be deleted in the database thread or not.

Definition at line 199 of file DatabasePager.h.

void osgDB::DatabasePager::setDoPreCompile ( bool  flag)
inline

Set whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph. Pre compilation helps reduce the chances of frame drops, but also slows the speed at which tiles are merged as they have to be compiled first.

Definition at line 181 of file DatabasePager.h.

void osgDB::DatabasePager::setDrawablePolicy ( DrawablePolicy  policy)
inline

Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.

Definition at line 213 of file DatabasePager.h.

void osgDB::DatabasePager::setIncrementalCompileOperation ( osgUtil::IncrementalCompileOperation ico)

Set the incremental compile operation. Used to manage the OpenGL object compilation and merging of subgraphs in a way that avoids overloading the rendering of frame with too many new objects in one frame.

void osgDB::DatabasePager::setMarkerObject ( osg::Object mo)
inline

Definition at line 289 of file DatabasePager.h.

void osgDB::DatabasePager::setMaxAnisotropyPolicy ( bool  changeAnisotropy,
float  valueAnisotropy 
)
inline

Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.

Definition at line 234 of file DatabasePager.h.

int osgDB::DatabasePager::setSchedulePriority ( OpenThreads::Thread::ThreadPriority  priority)

Set the priority of the database pager thread(s).

void osgDB::DatabasePager::setTargetMaximumNumberOfPageLOD ( unsigned int  target)
inline

Set the target maximum number of PagedLOD to maintain in memory. Note, if more than the target number are required for rendering of a frame then these active PagedLOD are excempt from being expiried. But once the number of active drops back below the target the inactive PagedLOD will be trimmed back to the target number.

Definition at line 192 of file DatabasePager.h.

void osgDB::DatabasePager::setUnrefImageDataAfterApplyPolicy ( bool  changeAutoUnRef,
bool  valueAutoUnRef 
)
inline

Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.

Definition at line 227 of file DatabasePager.h.

void osgDB::DatabasePager::setUpThreads ( unsigned int  totalNumThreads = 2,
unsigned int  numHttpThreads = 1 
)
virtual void osgDB::DatabasePager::signalBeginFrame ( const osg::FrameStamp framestamp)
virtual

Signal the database thread that the update, cull and draw has begun for a new frame. Note, this is called by the application so that the database pager can go to sleep while the CPU is busy on the main rendering threads.

virtual void osgDB::DatabasePager::signalEndFrame ( )
virtual

Signal the database thread that the update, cull and draw dispatch has completed. Note, this is called by the application so that the database pager can go to wake back up now the main rendering threads are iddle waiting for the next frame.

virtual void osgDB::DatabasePager::updateSceneGraph ( const osg::FrameStamp frameStamp)
virtual

Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph. Note, must only be called from single thread update phase.

Friends And Related Function Documentation

friend struct DatabasePagerCompileCompletedCallback
friend

Definition at line 413 of file DatabasePager.h.

friend struct DatabaseRequest
friend

Definition at line 298 of file DatabasePager.h.

friend class DatabaseThread
friend

Definition at line 297 of file DatabasePager.h.

friend class FindCompileableGLObjectsVisitor
friend

Definition at line 410 of file DatabasePager.h.

friend class FindPagedLODsVisitor
friend

Definition at line 416 of file DatabasePager.h.

friend struct SortFileRequestFunctor
friend

Definition at line 419 of file DatabasePager.h.

Member Data Documentation

bool osgDB::DatabasePager::_acceptNewRequests
protected

Definition at line 439 of file DatabasePager.h.

osg::ref_ptr<PagedLODList> osgDB::DatabasePager::_activePagedLODList
protected

Definition at line 464 of file DatabasePager.h.

bool osgDB::DatabasePager::_assignPBOToImages
protected

Definition at line 455 of file DatabasePager.h.

bool osgDB::DatabasePager::_changeAnisotropy
protected

Definition at line 458 of file DatabasePager.h.

bool osgDB::DatabasePager::_changeAutoUnRef
protected

Definition at line 456 of file DatabasePager.h.

bool osgDB::DatabasePager::_databasePagerThreadPaused
protected

Definition at line 440 of file DatabasePager.h.

DatabaseThreadList osgDB::DatabasePager::_databaseThreads
protected

Definition at line 442 of file DatabasePager.h.

osg::ref_ptr<RequestQueue> osgDB::DatabasePager::_dataToCompileList
protected

Definition at line 450 of file DatabasePager.h.

osg::ref_ptr<RequestQueue> osgDB::DatabasePager::_dataToMergeList
protected

Definition at line 451 of file DatabasePager.h.

bool osgDB::DatabasePager::_deleteRemovedSubgraphsInDatabaseThread
protected

Definition at line 461 of file DatabasePager.h.

bool osgDB::DatabasePager::_done
protected

Definition at line 438 of file DatabasePager.h.

bool osgDB::DatabasePager::_doPreCompile
protected

Definition at line 468 of file DatabasePager.h.

OpenThreads::Mutex osgDB::DatabasePager::_dr_mutex
protected

Definition at line 424 of file DatabasePager.h.

DrawablePolicy osgDB::DatabasePager::_drawablePolicy
protected

Definition at line 453 of file DatabasePager.h.

osg::ref_ptr<ReadQueue> osgDB::DatabasePager::_fileRequestQueue
protected

Definition at line 448 of file DatabasePager.h.

OpenThreads::Atomic osgDB::DatabasePager::_frameNumber
protected

Definition at line 446 of file DatabasePager.h.

osg::ref_ptr<ReadQueue> osgDB::DatabasePager::_httpRequestQueue
protected

Definition at line 449 of file DatabasePager.h.

osg::ref_ptr<osgUtil::IncrementalCompileOperation> osgDB::DatabasePager::_incrementalCompileOperation
protected

Definition at line 469 of file DatabasePager.h.

osg::ref_ptr<osg::Object> osgDB::DatabasePager::_markerObject
protected

Definition at line 477 of file DatabasePager.h.

double osgDB::DatabasePager::_maximumTimeToMergeTile
protected

Definition at line 473 of file DatabasePager.h.

double osgDB::DatabasePager::_minimumTimeToMergeTile
protected

Definition at line 472 of file DatabasePager.h.

int osgDB::DatabasePager::_numFramesActive
protected

Definition at line 444 of file DatabasePager.h.

OpenThreads::Mutex osgDB::DatabasePager::_numFramesActiveMutex
mutableprotected

Definition at line 445 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::_numTilesMerges
protected

Definition at line 475 of file DatabasePager.h.

OpenThreads::Mutex osgDB::DatabasePager::_run_mutex
protected

Definition at line 423 of file DatabasePager.h.

bool osgDB::DatabasePager::_startThreadCalled
protected

Definition at line 425 of file DatabasePager.h.

unsigned int osgDB::DatabasePager::_targetMaximumNumberOfPageLOD
protected

Definition at line 466 of file DatabasePager.h.

double osgDB::DatabasePager::_totalTimeToMergeTiles
protected

Definition at line 474 of file DatabasePager.h.

float osgDB::DatabasePager::_valueAnisotropy
protected

Definition at line 459 of file DatabasePager.h.

bool osgDB::DatabasePager::_valueAutoUnRef
protected

Definition at line 457 of file DatabasePager.h.


The documentation for this class was generated from the following file: