- Cal3D 0.11 API Reference -

cal3d::RefCounted Class Reference

Derive from RefCounted to make your class have reference-counted lifetime semantics. More...

#include <refcounted.h>

List of all members.

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)


Detailed Description

Derive from RefCounted to make your class have reference-counted lifetime semantics.

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.


Constructor & Destructor Documentation

virtual cal3d::RefCounted::~RefCounted  )  [inline, protected, virtual]
 

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.


The documentation for this class was generated from the following file:
Generated at Thu Jun 29 19:04:00 2006 by The Cal3D Team with Doxygen 1.4.6