DeleteHandler
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_DELETEHANDLER
#define OSG_DELETEHANDLER 1
#include <osg/Referenced>
#include <list>
namespace osg {
class OSG_EXPORT DeleteHandler
{
public:
typedef std::pair<unsigned int, const osg::Referenced*> FrameNumberObjectPair;
typedef std::list<FrameNumberObjectPair> ObjectsToDeleteList;
DeleteHandler(int numberOfFramesToRetainObjects=0);
virtual ~DeleteHandler();
void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects) { _numFramesToRetainObjects = numberOfFramesToRetainObjects; }
unsigned int getNumFramesToRetainObjects() const { return _numFramesToRetainObjects; }
void setFrameNumber(unsigned int frameNumber) { _currentFrameNumber = frameNumber; }
unsigned int getFrameNumber() const { return _currentFrameNumber; }
inline void doDelete(const Referenced* object) { delete object; }
virtual void flush();
virtual void flushAll();
virtual void requestDelete(const osg::Referenced* object);
protected:
DeleteHandler(const DeleteHandler&):
_numFramesToRetainObjects(0),
_currentFrameNumber(0) {}
DeleteHandler operator = (const DeleteHandler&) { return *this; }
unsigned int _numFramesToRetainObjects;
unsigned int _currentFrameNumber;
OpenThreads::Mutex _mutex;
ObjectsToDeleteList _objectsToDelete;
};
}
#endif
Referenced
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
osg::DeleteHandler::_objectsToDelete
ObjectsToDeleteList _objectsToDelete
Definition DeleteHandler:83
osg::DeleteHandler::doDelete
void doDelete(const Referenced *object)
Definition DeleteHandler:58
osg::DeleteHandler::~DeleteHandler
virtual ~DeleteHandler()
osg::DeleteHandler::getFrameNumber
unsigned int getFrameNumber() const
Definition DeleteHandler:56
osg::DeleteHandler::_mutex
OpenThreads::Mutex _mutex
Definition DeleteHandler:82
osg::DeleteHandler::FrameNumberObjectPair
std::pair< unsigned int, const osg::Referenced * > FrameNumberObjectPair
Definition DeleteHandler:36
osg::DeleteHandler::setFrameNumber
void setFrameNumber(unsigned int frameNumber)
Definition DeleteHandler:53
osg::DeleteHandler::ObjectsToDeleteList
std::list< FrameNumberObjectPair > ObjectsToDeleteList
Definition DeleteHandler:37
osg::DeleteHandler::DeleteHandler
DeleteHandler(int numberOfFramesToRetainObjects=0)
osg::DeleteHandler::getNumFramesToRetainObjects
unsigned int getNumFramesToRetainObjects() const
Definition DeleteHandler:50
osg::DeleteHandler::DeleteHandler
DeleteHandler(const DeleteHandler &)
Definition DeleteHandler:75
osg::DeleteHandler::setNumFramesToRetainObjects
void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects)
Definition DeleteHandler:48
osg::DeleteHandler::flush
virtual void flush()
osg::DeleteHandler::_numFramesToRetainObjects
unsigned int _numFramesToRetainObjects
Definition DeleteHandler:80
osg::DeleteHandler::_currentFrameNumber
unsigned int _currentFrameNumber
Definition DeleteHandler:81
osg::DeleteHandler::flushAll
virtual void flushAll()
osg::DeleteHandler::requestDelete
virtual void requestDelete(const osg::Referenced *object)
osg::Referenced
Definition Referenced:44
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39