Views
Foundation Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions
IlvSmartData Class Reference

Base class for reference counting. More...

#include <ilviews/base/smartptr.h>

Inheritance diagram for IlvSmartData:
IlvObservable IlvActionHistory IlvCommandHistory

Public Member Functions

 IlvSmartData ()
 Constructor. More...
 
 IlvSmartData (const IlvSmartData &data)
 Copy constructor. More...
 
virtual ~IlvSmartData ()
 Destructor.
 
void decrRef ()
 Decrements the reference counter of the object and deletes this object when the counter reaches 0. More...
 
void incrRef ()
 Increments the reference counter.
 
int refCount ()
 Returns the number of references to this object. More...
 

Detailed Description

Base class for reference counting.

Library: views

The class IlvSmartData provides functionality for reference counting and automatic deletion of nonreferenced objects. Objects of classes derived from IlvSmartData should not be explicitly deleted.

You should assign these objects a SmartPointer object that will maintain a reference counter to keep track of how many objects are pointing to them. The smart pointer does the following:

Instances of IlvSmartData subclasses can be created statically like all other objects, in which case they are destroyed when they come out of the scope of the current function. Pointers and smart pointers referencing objects that are out-of-scope become invalid as expected. Objects that are created statically are internally differentiated from objects that are created dynamically by setting their initial reference counter to 1 when they are created on the stack, and to 0 when they are created with the new operator.

See also
IlvSmartPointer.

Constructor & Destructor Documentation

◆ IlvSmartData() [1/2]

IlvSmartData::IlvSmartData ( )

Constructor.

Default constructor.

The initial reference count is set to 0, unless when the object is not created using the new operator. In this situation (the object is not created dynamically), the initial reference count is 1.

◆ IlvSmartData() [2/2]

IlvSmartData::IlvSmartData ( const IlvSmartData data)

Copy constructor.

The initial reference count is set to 0, unless when the object is not created using the new operator. In this situation (the object is not created dynamically), the initial reference count is 1.

Parameters
dataThe data to copy.

Member Function Documentation

◆ decrRef()

void IlvSmartData::decrRef ( )

Decrements the reference counter of the object and deletes this object when the counter reaches 0.

This method and the previous one are usually called by the IlvSmartPointer objects that point to the object. Therefore, you do not have to call it directly, unless you want to override the normal behavior of smart pointers temporarily.

◆ refCount()

int IlvSmartData::refCount ( )

Returns the number of references to this object.

Returns
The number of references pointing to this object.