NAME
vtkReferenceCount - subclasses of this object are reference counted
SYNOPSIS
#include "/opt/vtk-c++/common/vtkReferenceCount.h"
class VTK_EXPORT vtkReferenceCount : public vtkObject
vtkReferenceCount();
void Delete();
~vtkReferenceCount();
void PrintSelf(ostream& os, vtkIndent indent);
static vtkReferenceCount *New() {return new vtkReferenceCount;};
const char *GetClassName() {return "vtkReferenceCount";};
void Register(vtkObject* o);
void UnRegister(vtkObject* o);
int GetReferenceCount() {return this->ReferenceCount;};
void ReferenceCountingOff();
DESCRIPTION
vtkReferenceCount is the base class for objects that are reference counted. Objects that are reference counted exist as long as another object uses them. Once the last reference to a reference counted object is removed, the object will spontaneously destruct. Typically only data objects that are passed between objects are reference counted.
CAVEATS
Note: in vtk objects are generally created with combinations of new/Delete() methods. This works great until you want to allocate objects off the stack (i.e., automatic objects). Automatic objects, when automatically deleted (by exiting scope), will cause warnings to occur. You can avoid this by turing reference counting off (i.e., use the method ReferenceCountingOff()).
SEE ALSO
vtkLookupTable vtkTCoords vtkCellTypes vtkCellLinks vtkNormals vtkPoints vtkScalars vtkTensors vtkUserDefined vtkVectors
SUMMARY
void ReferenceCountingOff()
Turn off reference counting for this object. This allows you to create automatic reference counted objects and avoid warning messages when scope is existed. (Note: It is preferable to use the combination new/Delete() to create and delete vtk objects.)
vtkReferenceCount()
Construct with initial reference count = 1 and reference counting on.
void Delete()
Overload vtkObject's Delete() method. For reference counted objects the Delete() method simply unregisters the use of the object. This may or may not result in the destruction of the object, depending upon whether another object is referencing it.
~vtkReferenceCount()
Destructor for reference counted objects. Reference counted objects should almost always use the combination of new/Delete() to create and delete objects. Automatic reference counted objects (i.e., creating them on the stack) are not encouraged. However, if you desire to do this, you will have to use the ReferenceCountingOff() method to avoid warning messages when
the objects are automatically deleted upon scope termination.
void Register(vtkObject* o)
Increase the reference count (mark as used by another object).
void UnRegister(vtkObject* o)
Decrease the reference count (release by another object).