cee::RefCountedObject Class Reference

Base class for all reference counted objects with built-in support for intrusive reference counting. More...

Public Member Functions

void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 
Inheritance diagram for cee::RefCountedObject:
cee::Image cee::ImageResources cee::Instance cee::LogDestination cee::LogManager cee::PropertySet cee::PropertySetCollection cee::vtfx::Block cee::vtfx::Case cee::vtfx::Database cee::vtfx::File cee::vtfx::SetItemGroup

Detailed Description

Base class for all reference counted objects with built-in support for intrusive reference counting.

See Smart pointers for more information.

Warning
Classes that derive from this class should not be created on the stack. You should never manually delete them, only use the release() member function.

Member Function Documentation

void cee::RefCountedObject::addRef ( ) const

Increments the reference count for this object.

Objects use a reference counting mechanism to ensure that the lifetime of the object includes the lifetime of references to it. You use addRef() to stabilize a copy of an interface pointer. It can also be called when the life of a cloned pointer must extend beyond the lifetime of the original pointer. The cloned pointer must be released by calling release().

int cee::RefCountedObject::refCount ( ) const

Returns the reference count for this object.

void cee::RefCountedObject::release ( ) const

Decrements the reference count for this object.

Call this method when you no longer need to use an interface pointer.

void cee::RefCountedObject::setRefCountZero ( ) const

Sets the ref count to zero, but DOES NOT delete the object.

After this call, the refCount would be zero and the object is in a similar state with regards to refCount as it was when it was created with the new operator.

Note
Use with caution! The responsibility of the life cycle management of the object is now in the hands of the caller. Any PreRef's associated with this object must be detached using the PtrRef::detach() method.