#include <RCObject.h>
Inheritance diagram for nvutil::RCObject:
Public Member Functions | |
RCObject () | |
Default constructor. | |
NVSG_API void | addRef () const |
Increment reference count. | |
NVSG_API void | removeRef () const |
Decrement reference count. | |
NVSG_API void | markUnshareable () |
Mark the object as not shareable. | |
NVSG_API bool | isShareable () const |
Query for the current shareable state. | |
NVSG_API bool | isShared () const |
Get to know if the object is currently shared. | |
Protected Member Functions | |
RCObject (const RCObject &rhs) | |
Protected copy constructor. | |
RCObject & | operator= (const RCObject &rhs) |
Protected assignment operator. | |
virtual | ~RCObject () |
Protected destructor. |
Provides an interface for managing reference counted objects. RCObject
inherits from IAllocator
to utilize an optimized heap manager for small object allocation.
RCObject
can only be constructed on heap. The compiler will reject any attempt to construct a RCObject
on stack.
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.
The reference count of a newly created RCObject
initially is zero.
|
Default constructor. Initializes the reference count to zero. Newly created RCObjects are shareable by default. |
|
Protected copy constructor. Reference counted objects need to live on heap, so we prohibit construction on stack by making constructors and assignment protected. |
|
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(). |
|
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.
|
|
Decrement reference count.
|
|
Mark the object as not shareable.
If a
|
|
Query for the current shareable state.
|
|
Get to know if the object is currently shared.
If a
|
|
Protected assignment operator. Reference counted objects need to live on heap, so we prohibit construction on stack by making constructors and assignment protected. |