Rogue Wave Views Foundation Package API Reference Guide |
Rogue Wave Views Documentation Home |
Base class for reference counting. More...
#include <ilviews/base/smartptr.h>
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... | |
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.
IlvSmartPointer
. 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::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
.
data | The data to copy. |
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.
int IlvSmartData::refCount | ( | ) |
Returns the number of references to this object.
© Copyright 2016, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.