osg::DeleteHandler Class Reference

`#include <DeleteHandler>`

## Public Types

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

## Public Member Functions

| DeleteHandler (int numberOfFramesToRetainObjects=0)
virtual | ~DeleteHandler ()
void | setNumFramesToRetainObjects (unsigned int numberOfFramesToRetainObjects)
unsigned int | getNumFramesToRetainObjects () const
void | setFrameNumber (unsigned int frameNumber)
unsigned int | getFrameNumber () const
void | doDelete (const Referenced *object)
virtual void | flush ()
virtual void | flushAll ()
virtual void | requestDelete (const osg::Referenced *object)

## Protected Member Functions

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

## Protected Attributes

unsigned int | _numFramesToRetainObjects
unsigned int | _currentFrameNumber
OpenThreads::Mutex | _mutex
ObjectsToDeleteList | _objectsToDelete

## Detailed Description

Class for overriding the default delete behaviour so that users can implement their own object deletion schemes. This might be used to implement a protection scheme that avoids multiple threads deleting objects unintentionally. Note, the DeleteHandler cannot itself be reference counted, otherwise it would be responsible for deleting itself! A static auto_ptr<> is used internally in Referenced.cpp to manage the DeleteHandler's memory.

## Member Typedef Documentation

## FrameNumberObjectPair

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

## ObjectsToDeleteList

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

## Constructor & Destructor Documentation

## DeleteHandler() [1/2]

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

Referenced by DeleteHandler(), and operator=().

## ~DeleteHandler()

virtual osg::DeleteHandler::~DeleteHandler | ( |  | ) |

virtual

## DeleteHandler() [2/2]

osg::DeleteHandler::DeleteHandler | ( | const DeleteHandler & |  | ) |

inline protected

References _currentFrameNumber, _numFramesToRetainObjects, and DeleteHandler().

## Member Function Documentation

## doDelete()

void osg::DeleteHandler::doDelete | ( | const Referenced * | object | ) |

inline

## flush()

virtual void osg::DeleteHandler::flush | ( |  | ) |

virtual

Flush objects that are ready to be fully deleted.

## flushAll()

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.

## getFrameNumber()

unsigned int osg::DeleteHandler::getFrameNumber | ( |  | ) | const

inline

Get the current frame number.

References _currentFrameNumber.

## getNumFramesToRetainObjects()

unsigned int osg::DeleteHandler::getNumFramesToRetainObjects | ( |  | ) | const

inline

References _numFramesToRetainObjects.

## operator=()

DeleteHandler osg::DeleteHandler::operator= | ( | const DeleteHandler & |  | ) |

inline protected

References DeleteHandler().

## requestDelete()

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.

## setFrameNumber()

void osg::DeleteHandler::setFrameNumber | ( | unsigned int | frameNumber | ) |

inline

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

References _currentFrameNumber.

## setNumFramesToRetainObjects()

void osg::DeleteHandler::setNumFramesToRetainObjects | ( | unsigned int | numberOfFramesToRetainObjects | ) |

inline

Set the number of frames to retain objects that have been requested for deletion. When set to zero objects are deleted immediately, by setting to 1 they are kept around for an extra frame etc. The ability to retain objects for several frames is useful to prevent premature deletion when objects are still being used by graphics threads that use double buffering of rendering data structures with non ref_ptr<> pointers to scene graph elements.

References _numFramesToRetainObjects.

## Member Data Documentation

## _currentFrameNumber

unsigned int osg::DeleteHandler::_currentFrameNumber

protected

Referenced by DeleteHandler(), getFrameNumber(), and setFrameNumber().

## _mutex

OpenThreads::Mutex osg::DeleteHandler::_mutex

protected

## _numFramesToRetainObjects

unsigned int osg::DeleteHandler::_numFramesToRetainObjects

protected

Referenced by DeleteHandler(), getNumFramesToRetainObjects(), and setNumFramesToRetainObjects().

## _objectsToDelete

ObjectsToDeleteList osg::DeleteHandler::_objectsToDelete

protected

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

- DeleteHandler