# osgDB::DatabasePager Class Reference

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

Inheritance diagram for osgDB::DatabasePager:

[legend]
List of all members.

## Public Types

typedef std::list< osg::ref_ptr< osg::PagedLOD > > | PagedLODList
typedef std::set< osg::ref_ptr< osg::StateSet > > | StateSetList
typedef std::vector< osg::ref_ptr< osg::Drawable > > | DrawableList
typedef std::pair< StateSetList, DrawableList > | DataToCompile
typedef std::map< unsigned int, DataToCompile > | DataToCompileMap
typedef std::set< unsigned int > | ActiveGraphicsContexts

## Public Member Functions

| DatabasePager ()
virtual void | requestNodeFile (const std::string &fileName, osg::Group *group, float priority, const osg::FrameStamp *framestamp)
| Add a request to load a node file to end the the database request list.
virtual void | run ()
| Run does the database paging.
virtual int | cancel ()
| Cancel the database pager thread.
virtual void | clear ()
| Clear all internally cached structures.
void | setDatabasePagerThreadPause (bool pause)
| Set whether the database pager thread should be paused or not.
bool | getDatabasePagerThreadPause () const
| Get whether the database pager thread should is paused or not.
void | setAcceptNewDatabaseRequests (bool acceptNewRequests)
| Set whether new database request calls are accepted or ignored.
bool | getAcceptNewDatabaseRequests () const
| Get whether new database request calls are accepted or ignored.
void | setUseFrameBlock (bool useFrameBlock)
| Set the use of the frame block which, if enabled, blocks the DatabasePager from executing which the current frame is being drawn.
bool | getUseFrameBlock () const
| Get the whether UseFrameBlock is on or off.
Block * | getFrameBlock ()
void | setThreadPriorityDuringFrame (ThreadPriority duringFrame)
| Set the priority of the database pager thread during the frame (i.e.
ThreadPriority | getThreadPriorityDuringFrame () const
| Get the priority of the database pager thread during the frame.
void | setThreadPriorityOutwithFrame (ThreadPriority outwithFrame)
| Set the priority of the database pager thread when the frame is not being exectuted (i.e.
ThreadPriority | getThreadPriorityOutwithFrame () const
| Get the priority of the database pager thread when the frame is not being exectuted.
int | getNumFramesActive () const
| Get the number of frames that are currently active.
virtual void | signalBeginFrame (const osg::FrameStamp *framestamp)
| Signal the database thread that the update, cull and draw has begun for a new frame.
virtual void | signalEndFrame ()
| Signal the database thread that the update, cull and draw dispatch has completed.
virtual void | registerPagedLODs (osg::Node *subgraph)
| Find all PagedLOD nodes in a subgraph and register them with the DatabasePager so it can keep track of expired nodes.
void | setExpiryDelay (double expiryDelay)
| Set the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.
double | getExpiryDelay () const
| Get the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.
void | setDeleteRemovedSubgraphsInDatabaseThread (bool flag)
| set whether the removed subgraphs should be deleted in the database thread or not.
bool | getDeleteRemovedSubgraphsInDatabaseThread () const
| get whether the removed subgraphs should be deleted in the database thread or not.
void | setUnrefImageDataAfterApplyPolicy (bool changeAutoUnRef, bool valueAutoUnRef)
| set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.
void | getUnrefImageDataAfterApplyPolicy (bool &changeAutoUnRef, bool &valueAutoUnRef) const
| get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.
void | setMaxAnisotropyPolicy (bool changeAnisotropy, float valueAnisotropy)
| set whether newly loaded textures should have their MaxAnisotopy set to a specified value.
void | getMaxAnisotropyPolicy (bool &changeAnisotropy, float &valueAnisotropy) const
| set whether newly loaded textures should have their MaxAnisotopy set to a specified value.
bool | requiresUpdateSceneGraph () const
| Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double).
virtual void | updateSceneGraph (double currentFrameTime)
| Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph.
void | setCompileGLObjectsForContextID (unsigned int contextID, bool on)
| Turn the compilation of rendering objects for specfied graphics context on (true) or off(false).
bool | getCompileGLObjectsForContextID (unsigned int contextID)
| Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false).
bool | requiresCompileGLObjects () const
| Return true if there are pending compile operations that are required.
virtual void | compileGLObjects (osg::State &state, double &availableTime)
| Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph.

## Protected Types

typedef std::vector< osg::ref_ptr< DatabaseRequest > > | DatabaseRequestList
typedef std::vector< osg::ref_ptr< osg::Object > > | ObjectList

## Protected Member Functions

virtual | ~DatabasePager ()
void | updateDatabasePagerThreadBlock ()
void | updateFrameBlock (int delta)
void | removeExpiredSubgraphs (double currentFrameTime)
| Iterate through the active PagedLOD nodes children removing children which havn't been visited since specified expiryTime.
void | addLoadedDataToSceneGraph (double currentFrameTime)
| Add the loaded data to the scene graph.

## Protected Attributes

class | FindCompileableGLObjectsVisitor
class | FindPagedLODsVisitor
struct | SortFileRequestFunctor
OpenThreads::Mutex | _run_mutex
bool | _startThreadCalled
osg::ref_ptr< Block > | _databasePagerThreadBlock
bool | _done
bool | _acceptNewRequests
bool | _databasePagerThreadPaused
bool | _useFrameBlock
int | _numFramesActive
OpenThreads::Mutex | _numFramesActiveMutex
osg::ref_ptr< Block > | _frameBlock
int | _frameNumber
ThreadPriority | _threadPriorityDuringFrame
ThreadPriority | _threadPriorityOutwithFrame
DatabaseRequestList | _fileRequestList
OpenThreads::Mutex | _fileRequestListMutex
DatabaseRequestList | _dataToCompileList
OpenThreads::Mutex | _dataToCompileListMutex
bool | _changeAutoUnRef
bool | _valueAutoUnRef
bool | _changeAnisotropy
float | _valueAnisotropy
bool | _deleteRemovedSubgraphsInDatabaseThread
ObjectList | _childrenToDeleteList
OpenThreads::Mutex | _childrenToDeleteListMutex
DatabaseRequestList | _dataToMergeList
OpenThreads::Mutex | _dataToMergeListMutex
PagedLODList | _activePagedLODList
PagedLODList | _inactivePagedLODList
double | _expiryDelay
ActiveGraphicsContexts | _activeGraphicsContexts

## Friends

struct | DatabaseRequest

## Classes

struct | DatabaseRequest

## Detailed Description

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

## Member Typedef Documentation

typedef std::set<unsigned int> osgDB::DatabasePager::ActiveGraphicsContexts

typedef std::vector< osg::ref_ptr<DatabaseRequest> > osgDB::DatabasePager::DatabaseRequestList `[protected]`

typedef std::pair<StateSetList,DrawableList> osgDB::DatabasePager::DataToCompile

typedef std::map< unsigned int, DataToCompile > osgDB::DatabasePager::DataToCompileMap

typedef std::vector< osg::ref_ptr<osg::Drawable> > osgDB::DatabasePager::DrawableList

typedef std::vector< osg::ref_ptr<osg::Object> > osgDB::DatabasePager::ObjectList `[protected]`

typedef std::list< osg::ref_ptr<osg::PagedLOD> > osgDB::DatabasePager::PagedLODList

typedef std::set< osg::ref_ptr<osg::StateSet> > osgDB::DatabasePager::StateSetList

## Constructor & Destructor Documentation

osgDB::DatabasePager::DatabasePager | ( |  | ) |

virtual osgDB::DatabasePager::~DatabasePager | ( |  | ) | `[protected, virtual]`

## Member Function Documentation

void osgDB::DatabasePager::addLoadedDataToSceneGraph | ( | double | currentFrameTime | ) | `[protected]`

| Add the loaded data to the scene graph.

virtual int osgDB::DatabasePager::cancel | ( |  | ) | `[virtual]`

| Cancel the database pager thread.

virtual void osgDB::DatabasePager::clear | ( |  | ) | `[virtual]`

| Clear all internally cached structures.

virtual void osgDB::DatabasePager::compileGLObjects | ( | osg::State & | state,
|  | double & | availableTime
| ) | `[virtual]`

| Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph. note, should only be called from the draw thread. Note, must only be called from a valid graphics context.

bool osgDB::DatabasePager::getAcceptNewDatabaseRequests | ( |  | ) | const`[inline]`

| Get whether new database request calls are accepted or ignored.

bool osgDB::DatabasePager::getCompileGLObjectsForContextID | ( | unsigned int | contextID | ) |

| Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false).

bool osgDB::DatabasePager::getDatabasePagerThreadPause | ( |  | ) | const`[inline]`

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

bool osgDB::DatabasePager::getDeleteRemovedSubgraphsInDatabaseThread | ( |  | ) | const`[inline]`

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

double osgDB::DatabasePager::getExpiryDelay | ( |  | ) | const`[inline]`

| Get the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.

Block* osgDB::DatabasePager::getFrameBlock | ( |  | ) | `[inline]`

void osgDB::DatabasePager::getMaxAnisotropyPolicy | ( | bool & | changeAnisotropy,
|  | float & | valueAnisotropy
| ) | const`[inline]`

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

int osgDB::DatabasePager::getNumFramesActive | ( |  | ) | const`[inline]`

| Get the number of frames that are currently active.

ThreadPriority osgDB::DatabasePager::getThreadPriorityDuringFrame | ( |  | ) | const`[inline]`

| Get the priority of the database pager thread during the frame.

ThreadPriority osgDB::DatabasePager::getThreadPriorityOutwithFrame | ( |  | ) | const`[inline]`

| Get the priority of the database pager thread when the frame is not being exectuted.

void osgDB::DatabasePager::getUnrefImageDataAfterApplyPolicy | ( | bool & | changeAutoUnRef,
|  | bool & | valueAutoUnRef
| ) | const`[inline]`

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

bool osgDB::DatabasePager::getUseFrameBlock | ( |  | ) | const`[inline]`

| Get the whether UseFrameBlock is on or off.

virtual void osgDB::DatabasePager::registerPagedLODs | ( | osg::Node * | subgraph | ) | `[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.

void osgDB::DatabasePager::removeExpiredSubgraphs | ( | double | currentFrameTime | ) | `[protected]`

| 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::Group * | group,
|  | float | priority,
|  | const osg::FrameStamp * | framestamp
| ) | `[virtual]`

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

bool osgDB::DatabasePager::requiresCompileGLObjects | ( |  | ) | const

| Return true if there are pending compile operations that are required. If requiresCompileGLObjects() return true the application should call compileGLObjects() .

bool osgDB::DatabasePager::requiresUpdateSceneGraph | ( |  | ) | const

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

virtual void osgDB::DatabasePager::run | ( |  | ) | `[virtual]`

| Run does the database paging.

void osgDB::DatabasePager::setAcceptNewDatabaseRequests | ( | bool | acceptNewRequests | ) | `[inline]`

| Set whether new database request calls are accepted or ignored.

void osgDB::DatabasePager::setCompileGLObjectsForContextID | ( | unsigned int | contextID,
|  | bool | on
| ) |

| Turn the compilation of rendering objects for specfied graphics context on (true) or off(false).

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.

void osgDB::DatabasePager::setExpiryDelay | ( | double | expiryDelay | ) | `[inline]`

| Set the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.

void osgDB::DatabasePager::setMaxAnisotropyPolicy | ( | bool | changeAnisotropy,
|  | float | valueAnisotropy
| ) | `[inline]`

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

void osgDB::DatabasePager::setThreadPriorityDuringFrame | ( | ThreadPriority | duringFrame | ) | `[inline]`

| Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)

void osgDB::DatabasePager::setThreadPriorityOutwithFrame | ( | ThreadPriority | outwithFrame | ) | `[inline]`

| Set the priority of the database pager thread when the frame is not being exectuted (i.e. before or after cull and draw have run.)

void osgDB::DatabasePager::setUnrefImageDataAfterApplyPolicy | ( | bool | changeAutoUnRef,
|  | bool | valueAutoUnRef
| ) | `[inline]`

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

void osgDB::DatabasePager::setUseFrameBlock | ( | bool | useFrameBlock | ) | `[inline]`

| Set the use of the frame block which, if enabled, blocks the DatabasePager from executing which the current frame is being drawn. When a single processor machine is being used it can be useful to block on frame to help prevent the database paging thread from slowing the cull and draw traversals which in turn can cause frame drops.

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.

void osgDB::DatabasePager::updateDatabasePagerThreadBlock | ( |  | ) | `[inline, protected]`

void osgDB::DatabasePager::updateFrameBlock | ( | int | delta | ) | `[inline, protected]`

virtual void osgDB::DatabasePager::updateSceneGraph | ( | double | currentFrameTime | ) | `[inline, 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 DatabaseRequest `[friend]`

## Member Data Documentation

bool osgDB::DatabasePager::_acceptNewRequests `[protected]`

ActiveGraphicsContexts osgDB::DatabasePager::_activeGraphicsContexts `[protected]`

PagedLODList osgDB::DatabasePager::_activePagedLODList `[protected]`

bool osgDB::DatabasePager::_changeAnisotropy `[protected]`

bool osgDB::DatabasePager::_changeAutoUnRef `[protected]`

ObjectList osgDB::DatabasePager::_childrenToDeleteList `[protected]`

OpenThreads::Mutex osgDB::DatabasePager::_childrenToDeleteListMutex `[mutable, protected]`

osg::ref_ptr<Block> osgDB::DatabasePager::_databasePagerThreadBlock `[protected]`

bool osgDB::DatabasePager::_databasePagerThreadPaused `[protected]`

DatabaseRequestList osgDB::DatabasePager::_dataToCompileList `[protected]`

OpenThreads::Mutex osgDB::DatabasePager::_dataToCompileListMutex `[mutable, protected]`

DatabaseRequestList osgDB::DatabasePager::_dataToMergeList `[protected]`

OpenThreads::Mutex osgDB::DatabasePager::_dataToMergeListMutex `[mutable, protected]`

bool osgDB::DatabasePager::_deleteRemovedSubgraphsInDatabaseThread `[protected]`

bool osgDB::DatabasePager::_done `[protected]`

double osgDB::DatabasePager::_expiryDelay `[protected]`

DatabaseRequestList osgDB::DatabasePager::_fileRequestList `[protected]`

OpenThreads::Mutex osgDB::DatabasePager::_fileRequestListMutex `[mutable, protected]`

osg::ref_ptr<Block> osgDB::DatabasePager::_frameBlock `[protected]`

int osgDB::DatabasePager::_frameNumber `[protected]`

PagedLODList osgDB::DatabasePager::_inactivePagedLODList `[protected]`

int osgDB::DatabasePager::_numFramesActive `[protected]`

OpenThreads::Mutex osgDB::DatabasePager::_numFramesActiveMutex `[mutable, protected]`

OpenThreads::Mutex osgDB::DatabasePager::_run_mutex `[protected]`

bool osgDB::DatabasePager::_startThreadCalled `[protected]`

ThreadPriority osgDB::DatabasePager::_threadPriorityDuringFrame `[protected]`

ThreadPriority osgDB::DatabasePager::_threadPriorityOutwithFrame `[protected]`

bool osgDB::DatabasePager::_useFrameBlock `[protected]`

float osgDB::DatabasePager::_valueAnisotropy `[protected]`

bool osgDB::DatabasePager::_valueAutoUnRef `[protected]`

class friend class osgDB::DatabasePager::FindCompileableGLObjectsVisitor `[protected]`

class friend class osgDB::DatabasePager::FindPagedLODsVisitor `[protected]`

struct friend struct osgDB::DatabasePager::SortFileRequestFunctor `[protected]`

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

- DatabasePager