OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeleteHandler.h
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 
21 namespace 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 
50  unsigned int getNumFramesToRetainObjects() const { return _numFramesToRetainObjects; }
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 
76  _numFramesToRetainObjects(0),
77  _currentFrameNumber(0) {}
78  DeleteHandler operator = (const DeleteHandler&) { return *this; }
79 
81  unsigned int _currentFrameNumber;
83  ObjectsToDeleteList _objectsToDelete;
84 
85 };
86 
87 }
88 
89 #endif
#define OSG_EXPORT
Definition: Export.h:43
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
std::list< FrameNumberObjectPair > ObjectsToDeleteList
Definition: DeleteHandler.h:37
unsigned int _numFramesToRetainObjects
Definition: DeleteHandler.h:80
unsigned int _currentFrameNumber
Definition: DeleteHandler.h:81
OpenThreads::Mutex _mutex
Definition: DeleteHandler.h:82
void setFrameNumber(unsigned int frameNumber)
Definition: DeleteHandler.h:53
ObjectsToDeleteList _objectsToDelete
Definition: DeleteHandler.h:83
DeleteHandler(const DeleteHandler &)
Definition: DeleteHandler.h:75
Definition: AlphaFunc.h:19
unsigned int getNumFramesToRetainObjects() const
Definition: DeleteHandler.h:50
std::pair< unsigned int, const osg::Referenced * > FrameNumberObjectPair
Definition: DeleteHandler.h:36
void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects)
Definition: DeleteHandler.h:48
void doDelete(const Referenced *object)
Definition: DeleteHandler.h:58
unsigned int getFrameNumber() const
Definition: DeleteHandler.h:56