osg::DeleteHandler Class Reference

Class for override the default delete behavior so that users can implement their own object deletion schemes. More...

List of all members.

Public Types

typedef std::pair
< int, const
osg::Referenced * > 
FrameNumberObjectPair
typedef std::list
< FrameNumberObjectPair
ObjectsToDeleteList

Public Member Functions

 DeleteHandler (int numberOfFramesToRetainObjects=0)
virtual ~DeleteHandler ()
void setNumFramesToRetainObjects (int numberOfFramesToRetainObjects)
 Set the number of frames to retain objects that are have been requested for deletion.
int getNumFramesToRetainObjects () const
void setFrameNumber (int frameNumber)
 Set the current frame numberso that subsequent deletes get tagged as associated with this frame.
int getFrameNumber () const
 Get the current frame number.
void doDelete (const Referenced *object)
virtual void flush ()
 Flush objects that ready to be fully deleted.
virtual void flushAll ()
 Flush all objects that the DeleteHandler holds.
virtual void requestDelete (const osg::Referenced *object)
 Request the deletion of an object.

Protected Member Functions

 DeleteHandler (const DeleteHandler &)
DeleteHandler operator= (const DeleteHandler &)

Protected Attributes

int _numFramesToRetainObjects
int _currentFrameNumber
OpenThreads::Mutex _mutex
ObjectsToDeleteList _objectsToDelete


Detailed Description

Class for override the default delete behavior so that users can implement their own object deletion schemes.

This might be done to help implement protection of multiple threads from deleting objects unintentionally. Note, the DeleteHandler cannot itself be reference counted, otherwise it would be responsible for deleting itself! An static auto_ptr<> is used internally in Referenced.cpp to manage the DeleteHandler's memory.


Member Typedef Documentation

typedef std::pair<int, const osg::Referenced*> osg::DeleteHandler::FrameNumberObjectPair

typedef std::list<FrameNumberObjectPair> osg::DeleteHandler::ObjectsToDeleteList


Constructor & Destructor Documentation

osg::DeleteHandler::DeleteHandler ( int  numberOfFramesToRetainObjects = 0  ) 

virtual osg::DeleteHandler::~DeleteHandler (  )  [virtual]

osg::DeleteHandler::DeleteHandler ( const DeleteHandler  )  [inline, protected]


Member Function Documentation

void osg::DeleteHandler::setNumFramesToRetainObjects ( int  numberOfFramesToRetainObjects  )  [inline]

Set the number of frames to retain objects that are have been requested for deletion.

When set to zero objects are deleted immediately, by set to 1 there are kept around for an extra frame etc. The ability to retain obejcts for several frames is useful to prevent premature deletion when objects are stil be used the graphics threads that are using double buffering of rendering data structures with non ref_ptr<> pointers to scene graph elements.

int osg::DeleteHandler::getNumFramesToRetainObjects (  )  const [inline]

void osg::DeleteHandler::setFrameNumber ( int  frameNumber  )  [inline]

Set the current frame numberso that subsequent deletes get tagged as associated with this frame.

int osg::DeleteHandler::getFrameNumber (  )  const [inline]

Get the current frame number.

void osg::DeleteHandler::doDelete ( const Referenced object  )  [inline]

virtual void osg::DeleteHandler::flush (  )  [virtual]

Flush objects that ready to be fully deleted.

virtual void osg::DeleteHandler::flushAll (  )  [virtual]

Flush all objects that the DeleteHandler holds.

Note, this should only be called if there are no threads running with non ref_ptr<> pointers, such as graphics threads.

virtual void osg::DeleteHandler::requestDelete ( const osg::Referenced object  )  [virtual]

Request the deletion of an object.

Depending on users implementation of DeleteHandler, the delete of the object may occur straight away or be delayed until doDelete is called. The default implementation does a delete straight away.

DeleteHandler osg::DeleteHandler::operator= ( const DeleteHandler  )  [inline, protected]


Member Data Documentation

int osg::DeleteHandler::_numFramesToRetainObjects [protected]

int osg::DeleteHandler::_currentFrameNumber [protected]

OpenThreads::Mutex osg::DeleteHandler::_mutex [protected]

ObjectsToDeleteList osg::DeleteHandler::_objectsToDelete [protected]


The documentation for this class was generated from the following file:
Generated at Sun Oct 14 02:12:07 2007 for the OpenSceneGraph by doxygen 1.5.3.