OpenSceneGraph 3.6.5
DeleteHandler
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_DELETEHANDLER
15#define OSG_DELETEHANDLER 1
16
17#include <osg/Referenced>
18
19#include <list>
20
21namespace osg {
22
23
33{
34 public:
35
36 typedef std::pair<unsigned int, const osg::Referenced*> FrameNumberObjectPair;
37 typedef std::list<FrameNumberObjectPair> ObjectsToDeleteList;
38
39 DeleteHandler(int numberOfFramesToRetainObjects=0);
40
41 virtual ~DeleteHandler();
42
48 void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects) { _numFramesToRetainObjects = numberOfFramesToRetainObjects; }
49
51
53 void setFrameNumber(unsigned int frameNumber) { _currentFrameNumber = frameNumber; }
54
56 unsigned int getFrameNumber() const { return _currentFrameNumber; }
57
58 inline void doDelete(const Referenced* object) { delete object; }
59
61 virtual void flush();
62
65 virtual void flushAll();
66
71 virtual void requestDelete(const osg::Referenced* object);
72
73 protected:
74
78 DeleteHandler operator = (const DeleteHandler&) { return *this; }
79
81 unsigned int _currentFrameNumber;
82 OpenThreads::Mutex _mutex;
84
85};
86
87}
88
89#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
ObjectsToDeleteList _objectsToDelete
Definition DeleteHandler:83
void doDelete(const Referenced *object)
Definition DeleteHandler:58
virtual ~DeleteHandler()
unsigned int getFrameNumber() const
Get the current frame number.
Definition DeleteHandler:56
OpenThreads::Mutex _mutex
Definition DeleteHandler:82
std::pair< unsigned int, const osg::Referenced * > FrameNumberObjectPair
Definition DeleteHandler:36
void setFrameNumber(unsigned int frameNumber)
Set the current frame number so that subsequent deletes get tagged as associated with this frame.
Definition DeleteHandler:53
std::list< FrameNumberObjectPair > ObjectsToDeleteList
Definition DeleteHandler:37
DeleteHandler(int numberOfFramesToRetainObjects=0)
unsigned int getNumFramesToRetainObjects() const
Definition DeleteHandler:50
DeleteHandler(const DeleteHandler &)
Definition DeleteHandler:75
void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects)
Set the number of frames to retain objects that have been requested for deletion.
Definition DeleteHandler:48
virtual void flush()
Flush objects that are ready to be fully deleted.
unsigned int _numFramesToRetainObjects
Definition DeleteHandler:80
unsigned int _currentFrameNumber
Definition DeleteHandler:81
virtual void flushAll()
Flush all objects that the DeleteHandler holds.
virtual void requestDelete(const osg::Referenced *object)
Request the deletion of an object.
Base class for providing reference counted objects.
Definition Referenced:44
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.