#include <psharedptr.h>
Inheritance diagram for PSharedPtr< T >:
Public Types | |
typedef T | element_type |
Public Member Functions | |
PSharedPtr (element_type *_ptr=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 |
typedef T PSharedPtr< T >::element_type |
PSharedPtr< T >::PSharedPtr | ( | element_type * | _ptr = NULL |
) | [inline] |
PSharedPtr< T >::PSharedPtr | ( | const PSharedPtr< T > & | c | ) | [inline] |
PSharedPtr< T >::PSharedPtr | ( | std::auto_ptr< element_type > & | v | ) | [inline] |
virtual PSharedPtr< T >::~PSharedPtr | ( | ) | [inline, virtual] |
PSharedPtr< T >::PSharedPtr | ( | int | dummy, | |
const PSharedPtr< T > * | c | |||
) | [inline, protected] |
PSharedPtr& PSharedPtr< T >::operator= | ( | const PSharedPtr< T > & | c | ) | [inline] |
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.
PBoolean PSharedPtr< T >::SetSize | ( | PINDEX | ) | [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 >::Get | ( | ) | const [inline] |
void PSharedPtr< T >::Reset | ( | ) | const [inline] |
T& PSharedPtr< T >::operator * | ( | ) | const [inline] |
T* PSharedPtr< T >::operator-> | ( | ) | const [inline] |
void PSharedPtr< T >::AssignContents | ( | const PContainer & | c | ) | [inline, protected, virtual] |
Copy the container contents. This copies the contents from one reference to another.
No duplication of contents occurs, for instance if the container is an array, the pointer to the array memory is copied, not the array memory block itself.
This function will get called by the base assignment operator.
Reimplemented from PContainer.
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.
void PSharedPtr< T >::CloneContents | ( | const PContainer * | src | ) | [inline, protected] |
Create a duplicate of the container contents. This copies the contents from one container to another, unique container. It is automatically declared when the PDECLARE_CONTAINER()# macro is used.
This class will duplicate the contents completely, for instance if the container is an array, the actual array memory is copied, not just the pointer. If the container contains objects that descend from PObject#, they too should also be cloned and not simply copied.
This function will get called once for every class in the heirarchy, so the ancestor function should { not} be called.
{ { Note well}}, the logic of the function must be able to accept the passed in parameter to clone being the same instance as the destination object, ie during execution this == src#.
Reimplemented from PContainer.
void PSharedPtr< T >::CopyContents | ( | const PContainer & | c | ) | [inline, protected] |
Copy the container contents. This copies the contents from one reference to another. It is automatically declared when the PDECLARE_CONTAINER()# macro is used.
No duplication of contents occurs, for instance if the container is an array, the pointer to the array memory is copied, not the array memory block itself.
This function will get called once for every class in the heirarchy, so the ancestor function should { not} be called.
Reimplemented from PContainer.
T* PSharedPtr< T >::ptr [protected] |