PSmartPointer Class Reference

This is the class for pointers to objects that use the smart pointer system. More...

#include <smartptr.h>

Inheritance diagram for PSmartPointer:

PObject PNotifierTemplate< ParmType > PSmartPtr< T > List of all members.

Public Member Functions

Construction
 PSmartPointer (PSmartObject *obj=NULL)
 Create a new smart pointer instance and have it point to the specified PSmartObject instance.
 PSmartPointer (const PSmartPointer &ptr)
 Create a new smart pointer and point it at the data pointed to by the ptr parameter.
virtual ~PSmartPointer ()
 Destroy the smart pointer and decrement the reference count on the object being pointed to.
PSmartPointeroperator= (const PSmartPointer &ptr)
 Assign this pointer to the value specified in the ptr parameter.
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
 Determine the relative rank of the pointers.
Pointer access functions
PBoolean IsNULL () const
 Determine if the smart pointer has been set to point to an actual object instance.
PSmartObjectGetObject () const
 Get the current value if the internal smart object pointer.

Protected Attributes

PSmartObjectobject
 Object the smart pointer points to.

Detailed Description

This is the class for pointers to objects that use the smart pointer system.

In conjunction with the PSmartObject class, this class references objects that can have the automatic deletion of the object instance when there are no more smart pointer instances pointing to it.

A PSmartPointer carries the pointer to a PSmartObject instance which contains a reference count. Assigning or copying instances of smart pointers will automatically increment and decrement the reference count. When the last instance that references a PSmartObject instance is destroyed or overwritten, the PSmartObject is deleted.

A NULL value is possible for a smart pointer. It can be detected via the IsNULL() function.


Constructor & Destructor Documentation

PSmartPointer::PSmartPointer ( PSmartObject obj = NULL  )  [inline]

Create a new smart pointer instance and have it point to the specified PSmartObject instance.

Parameters:
obj  Smart object to point to.

PSmartPointer::PSmartPointer ( const PSmartPointer ptr  ) 

Create a new smart pointer and point it at the data pointed to by the ptr parameter.

The reference count for the object being pointed at is incremented.

Parameters:
ptr  Smart pointer to make a copy of.

virtual PSmartPointer::~PSmartPointer (  )  [virtual]

Destroy the smart pointer and decrement the reference count on the object being pointed to.

If there are no more references then the object is deleted.


Member Function Documentation

virtual Comparison PSmartPointer::Compare ( const PObject obj  )  const [virtual]

Determine the relative rank of the pointers.

This is identical to determining the relative rank of the integer values represented by the memory pointers.

Returns:
EqualTo if objects point to the same object instance, otherwise LessThan and GreaterThan may be returned depending on the relative values of the memory pointers.
Parameters:
obj  Other smart pointer to compare against.

Reimplemented from PObject.

PSmartObject* PSmartPointer::GetObject (  )  const [inline]

Get the current value if the internal smart object pointer.

Returns:
pointer to object instance.

PBoolean PSmartPointer::IsNULL (  )  const [inline]

Determine if the smart pointer has been set to point to an actual object instance.

Returns:
true if the pointer is NULL.

PSmartPointer& PSmartPointer::operator= ( const PSmartPointer ptr  ) 

Assign this pointer to the value specified in the ptr parameter.

The previous object being pointed to has its reference count decremented as this will no longer point to it. If there are no more references then the object is deleted.

The new object being pointed to after the assignment has its reference count incremented.

Parameters:
ptr  Smart pointer to assign.


Member Data Documentation

PSmartObject* PSmartPointer::object [protected]

Object the smart pointer points to.


The documentation for this class was generated from the following file:
Generated on Fri Oct 14 01:44:12 2011 for PTLib by  doxygen 1.4.7