- Cal3D 0.11 API Reference - |
#include <refcounted.h>
Public Member Functions | |
int | getRefCount () const |
Protected Member Functions | |
virtual | ~RefCounted () |
Protected so users of refcounted classes don't use std::auto_ptr or the delete operator. | |
Friends | |
template<typename T> | |
T * | explicitIncRef (T *p) |
void | explicitDecRef (RefCounted *p) |
Use RefPtr to manage references. (Don't call incRef() or decRef() directly.) When deriving from RefCounted, make your destructor protected so manual deletion won't happen on accident.
Note: The reference count is initialized to 0. This makes sense, because, at object construction, no RefPtrs have referenced the object. However, this can cause trouble if you (indirectly) make a RefPtr to 'this' within your constructor. When the refptr goes out of scope, the count goes back to 0, and the object is deleted before it even exits the constructor. Current recommended solution: Don't make refptrs to 'this'. Pass 'this' by raw pointer and such.
|
Protected so users of refcounted classes don't use std::auto_ptr or the delete operator. Interfaces that derive from RefCounted should define an inline, empty, protected destructor as well. |