#include <SGSharedPtr.hxx>
Public Member Functions | |
| SGSharedPtr (void) | |
| SGSharedPtr (T *ptr) | |
| SGSharedPtr (const SGSharedPtr &p) | |
| template<typename U> | |
| SGSharedPtr (const SGSharedPtr< U > &p) | |
| ~SGSharedPtr (void) | |
| SGSharedPtr & | operator= (const SGSharedPtr &p) |
| template<typename U> | |
| SGSharedPtr & | operator= (const SGSharedPtr< U > &p) |
| template<typename U> | |
| SGSharedPtr & | operator= (U *p) |
| T * | operator-> (void) const |
| T & | operator * (void) const |
| operator T * (void) const | |
| T * | ptr (void) const |
| bool | isShared (void) const |
| unsigned | getNumRefs (void) const |
| bool | valid (void) const |
The SGSharedPtr class handles reference counting and possible destruction if no nore references are in use automatically. Classes derived from can be handled with SGSharedPtr. Once you have a SGSharedPtr available you can use it just like a usual pointer with the exception that you don't need to delete it. Such a reference is initialized by zero if not initialized with a class pointer. One thing you need to avoid are cyclic loops with such pointers. As long as such a cyclic loop exists the reference count never drops to zero and consequently the objects will never be destroyed. Always try to use directed graphs where the references away from the top node are made with SGSharedPtr's and the back references are done with ordinary pointers. There is a very good description of OpenSceneGraphs ref_ptr which is pretty much the same than this one at http://dburns.dhs.org/OSG/Articles/RefPointers/RefPointers.html
Definition at line 46 of file SGSharedPtr.hxx.
1.5.1