#include <smartptr.h>
Inheritance diagram for PSmartPointer:
Public Member Functions | |
Construction | |
PSmartPointer (PSmartObject *obj=NULL) | |
PSmartPointer (const PSmartPointer &ptr) | |
virtual | ~PSmartPointer () |
PSmartPointer & | operator= (const PSmartPointer &ptr) |
Overrides from class PObject | |
virtual Comparison | Compare (const PObject &obj) const |
Pointer access functions | |
PBoolean | IsNULL () const |
PSmartObject * | GetObject () const |
Protected Attributes | |
PSmartObject * | object |
Object the smart pointer points to. |
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.
PSmartPointer::PSmartPointer | ( | PSmartObject * | obj = NULL |
) | [inline] |
Create a new smart pointer instance and have it point to the specified PSmartObject# instance.
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.
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.
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.
Reimplemented from PObject.
PSmartObject* PSmartPointer::GetObject | ( | ) | const [inline] |
Get the current value if the internal smart object pointer.
PBoolean PSmartPointer::IsNULL | ( | ) | const [inline] |
Determine if the smart pointer has been set to point to an actual object instance.
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.
ptr | Smart pointer to assign. |
PSmartObject* PSmartPointer::object [protected] |
Object the smart pointer points to.