Inheritance diagram for SharedObj:
This class implements reference counting and automatic self destruction if there is no more references.
The objects of any derived class should be created using new operator. These objects must be destroyed using detach() method.
It is recommended to use virtual derivation for derived classes.
This class is used with SharedPtr template.
class MyObj: public virtual SharedObj { // ... };
SharedObj | ( | ) | [protected] |
Construction.
This constructor initializes object without references (i.e. number of references is equal to zero).
~SharedObj | ( | ) | [protected, virtual] |
Destruction.
The destructor checks that this objects has no references (i.e. number of references is equal to zero).
Objects created using new, should be deleted using detach() method.
long N_refs | ( | ) | const |
Number of references.
This method returns the current number of references.
void attach | ( | ) |
Add reference.
This method increases number of references.
bool detach | ( | ) |
Remove reference.
This method decreases number of references. If there is no more references, then object will be automatically deleted using delete operator.