Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

nvutil::RCObject Class Reference

A reference counted object interface. More...

#include <RCObject.h>

Inheritance diagram for nvutil::RCObject:

Inheritance graph
[legend]
Collaboration diagram for nvutil::RCObject:

Collaboration graph
[legend]
List of all members.

Public Methods

 RCObject ()
 Default constructor. More...

NVSG_API void addRef () const
 Increment reference count. More...

NVSG_API void removeRef () const
 Decrement reference count. More...

NVSG_API void markUnshareable ()
 Mark the object as not shareable. More...

NVSG_API bool isShareable () const
 Query for the current shareable state. More...

NVSG_API bool isShared () const
 Get to know if the object is currently shared. More...


Protected Methods

 RCObject (const RCObject &rhs)
 Protected copy constructor. More...

RCObject & operator= (const RCObject &rhs)
 Protected assignment operator. More...

virtual ~RCObject ()
 Protected destructor. More...


Detailed Description

A reference counted object interface.

Provides an interface for managing reference counted objects. RCObject inherits from IAllocator to utilize an optimized heap manager for small object allocation.

The purpose of a reference counted object is to share its data with other reference counted objects as long as this is possible. If a certain reference counted bject is constructed from another reference counted bject, it will initially share its data with that source object, same with assignment. That sharing can be sustained as long as non of the objects will be modified.

Note:
A RCObject can only be constructed on heap. The compiler will reject any attempt to construct a RCObject on stack.
Note:
It is prohibited to explicitely delete a RCObject by calling delete on a pointer to a RCObject received from a previous call to new. The compiler will complain, if any client code attempts to do so. If client code creates a RCObject, it must increment the object's reference count (addRef) before using it and decrement the object's reference count (removeRef) after usage. The object will be automatically deleted, if it's reference count reaches zero.
Note:
The reference count of a newly created RCObject initially is zero.


Constructor & Destructor Documentation

nvutil::RCObject::RCObject   [inline]
 

Default constructor.

Initializes the reference count to zero. Newly created RCObjects are shareable by default.

nvutil::RCObject::RCObject const RCObject &    rhs [inline, protected]
 

Protected copy constructor.

Reference counted objects need to live on heap, so we prohibit construction on stack by making constructors and assignment protected.

virtual nvutil::RCObject::~RCObject   [inline, protected, virtual]
 

Protected destructor.

To prohibit explicit deletion of reference counted objects, the destructor is protected. Reference counted objects cannot deleted other than by being unreferenced with removeRef().


Member Function Documentation

void nvutil::RCObject::addRef   const [inline]
 

Increment reference count.

For client code to ensure that the data of a reference counted object is valid as long as it uses the object, it should first increment the objects reference count. After usage, client code should decrement the objects reference count to avoid resource leaks.

Note:
The reference count of a newly created RCObject initially is zero.

void nvutil::RCObject::removeRef   const [inline]
 

Decrement reference count.

Note:
It is prohibited to explicitely delete a RCObject. The object will be automatically deleted, if reference count yields zero.

void nvutil::RCObject::markUnshareable   [inline]
 

Mark the object as not shareable.

If a RCObject is marked as not shareable, it will never share its data with other RCObjects.

Note:
An RCObject initially is shareable.

bool nvutil::RCObject::isShareable   const [inline]
 

Query for the current shareable state.

Note:
An RCObject initially is shareable.
Returns:
true if shareable, false otherwise.

bool nvutil::RCObject::isShared   const [inline]
 

Get to know if the object is currently shared.

If a RCObject has been constructed from a shareable RCObject, it initially shares its data with that object.

Returns:
true if currently shared, false otherwise.

RCObject& nvutil::RCObject::operator= const RCObject &    rhs [inline, protected]
 

Protected assignment operator.

Reference counted objects need to live on heap, so we prohibit construction on stack by making constructors and assignment protected.


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:20:46 2005 for NVSGSDK by NVIDIA