SharedObj Class Reference

Inheritance diagram for SharedObj:

NonCopyable List of all members.

Detailed Description

Reference counting.

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 {
    // ...
  };

See also:
Указатель с подсчётом ссылок

Public Member Functions

Protected Member Functions


Constructor & Destructor Documentation

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.


Member Function Documentation

long N_refs (  )  const

Number of references.

This method returns the current number of references.

Returns:
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.

Returns:
true If object was destroyed, otherwise false.


Generated on Wed Jun 6 17:27:47 2007 for OMNI by  doxygen 1.5.2