#include <psharedptr.h>
Public Types | |
typedef T | element_type |
Public Member Functions | |
PSharedPtr (element_type *p=NULL) | |
PSharedPtr (const PSharedPtr &c) | |
PSharedPtr (std::auto_ptr< element_type > &v) | |
PSharedPtr & | operator= (const PSharedPtr &c) |
virtual | ~PSharedPtr () |
virtual PBoolean | MakeUnique () |
PBoolean | SetSize (PINDEX) |
T * | Get () const |
void | Reset () const |
T & | operator* () const |
T * | operator-> () const |
Protected Member Functions | |
PSharedPtr (int dummy, const PSharedPtr *c) | |
void | AssignContents (const PContainer &c) |
void | DestroyContents () |
void | CloneContents (const PContainer *src) |
void | CopyContents (const PContainer &c) |
Protected Attributes | |
T * | ptr |
These templates implement an pointner class with an integral reference count based on the PContainer base class. This allows the easy creation of an a reference counted ptr that will autodestruct when the last reference goes out of scope.
typedef T PSharedPtr< T >::element_type |
PSharedPtr< T >::PSharedPtr | ( | element_type * | p = NULL |
) | [inline] |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::Reset().
PSharedPtr< T >::PSharedPtr | ( | const PSharedPtr< T > & | c | ) | [inline] |
References PSharedPtr< T >::CopyContents().
PSharedPtr< T >::PSharedPtr | ( | std::auto_ptr< element_type > & | v | ) | [inline] |
References PSharedPtr< T >::ptr.
virtual PSharedPtr< T >::~PSharedPtr | ( | ) | [inline, virtual] |
References PContainer::Destruct().
PSharedPtr< T >::PSharedPtr | ( | int | dummy, | |
const PSharedPtr< T > * | c | |||
) | [inline, protected] |
References PSharedPtr< T >::CloneContents().
void PSharedPtr< T >::AssignContents | ( | const PContainer & | c | ) | [inline, protected] |
References PSharedPtr< T >::CopyContents().
Referenced by PSharedPtr< T >::operator=(), and PSharedPtr< T >::Reset().
void PSharedPtr< T >::CloneContents | ( | const PContainer * | src | ) | [inline, protected] |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::MakeUnique(), and PSharedPtr< T >::PSharedPtr().
void PSharedPtr< T >::CopyContents | ( | const PContainer & | c | ) | [inline, protected] |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::AssignContents(), and PSharedPtr< T >::PSharedPtr().
void PSharedPtr< T >::DestroyContents | ( | ) | [inline, protected, virtual] |
Destroy the container contents. This function must be defined by the descendent class to do the actual destruction of the contents. It is automatically declared when the PDECLARE_CONTAINER()# macro is used.
For all descendent classes not immediately inheriting off the PContainer itself, the implementation of DestroyContents() should always call its ancestors function. This is especially relevent if many of the standard container classes, such as arrays, are descended from as memory leaks will occur.
Implements PContainer.
References PSharedPtr< T >::ptr.
T* PSharedPtr< T >::Get | ( | ) | const [inline] |
References PSharedPtr< T >::ptr.
virtual PBoolean PSharedPtr< T >::MakeUnique | ( | ) | [inline, virtual] |
Make this instance to be the one and only reference to the container contents. This implicitly does a clone of the contents of the container to make a unique reference. If the instance was already unique then the function does nothing.
Reimplemented from PContainer.
References PSharedPtr< T >::CloneContents(), PContainer::MakeUnique(), PFalse, and PTrue.
T& PSharedPtr< T >::operator* | ( | ) | const [inline] |
References PSharedPtr< T >::ptr.
T* PSharedPtr< T >::operator-> | ( | ) | const [inline] |
References PSharedPtr< T >::ptr.
PSharedPtr& PSharedPtr< T >::operator= | ( | const PSharedPtr< T > & | cont | ) | [inline] |
Assign one container reference to another. Set the current container to reference the same thing as the container specified in the parameter.
Note that the old contents of the container is dereferenced and if it was unique, destroyed using the DestroyContents() function.
Reimplemented from PContainer.
References PSharedPtr< T >::AssignContents().
void PSharedPtr< T >::Reset | ( | ) | const [inline] |
References PSharedPtr< T >::AssignContents(), and PSharedPtr< T >::PSharedPtr().
PBoolean PSharedPtr< T >::SetSize | ( | PINDEX | newSize | ) | [inline, virtual] |
Set the new current size of the container. The exact behavious of this is determined by the descendent class. For instance an array class would reallocate memory to make space for the new number of elements.
Note for some types of containers this does not do anything as they inherently only contain one item. The function returns PTrue always and the new value is ignored.
Implements PContainer.
T* PSharedPtr< T >::ptr [protected] |