PTLib
Version 2.14.3
|
These templates implement an pointner class with an integral reference count based on the PContainer base class. More...
#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 () |
Make this instance to be the one and only reference to the container contents. More... | |
PBoolean | SetSize (PINDEX) |
Set the new current size of the container. More... | |
T * | Get () const |
void | Reset () const |
T & | operator* () const |
T * | operator-> () const |
![]() | |
PContainer (PINDEX initialSize=0) | |
Create a new unique container. More... | |
PContainer (const PContainer &cont) | |
Create a new refernce to container. More... | |
PContainer & | operator= (const PContainer &cont) |
Assign one container reference to another. More... | |
virtual | ~PContainer () |
Destroy the container class. More... | |
virtual PINDEX | GetSize () const |
Get the current size of the container. More... | |
__inline size_t | size () const |
PBoolean | SetMinSize (PINDEX minSize) |
Set the minimum size of container. More... | |
virtual PBoolean | IsEmpty () const |
Determine if the container is empty. More... | |
__inline bool | empty () const |
PBoolean | IsUnique () const |
Determine if container is unique reference. More... | |
![]() | |
unsigned | GetTraceContextIdentifier () const |
Get PTRACE context identifier. More... | |
void | SetTraceContextIdentifier (unsigned id) |
void | GetTraceContextIdentifier (PObject &obj) |
void | GetTraceContextIdentifier (PObject *obj) |
void | SetTraceContextIdentifier (const PObject &obj) |
void | SetTraceContextIdentifier (const PObject *obj) |
virtual | ~PObject () |
virtual PObject * | Clone () const |
Create a copy of the class on the heap. More... | |
template<class CLS > | |
CLS * | CloneAs () const |
As for Clone() but converts to specified type. More... | |
virtual PINDEX | HashFunction () const |
This function yields a hash value required by the PDictionary class. More... | |
virtual const char * | GetClass (unsigned ancestor=0) const |
Get the current dynamic type of the object instance. More... | |
PBoolean | IsClass (const char *cls) const |
virtual PBoolean | InternalIsDescendant (const char *clsName) const |
Determine if the dynamic type of the current instance is a descendent of the specified class. More... | |
__inline const PObject * | PTraceObjectInstance () const |
virtual Comparison | Compare (const PObject &obj) const |
Compare the two objects and return their relative rank. More... | |
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
Determine the byte wise comparison of two objects. More... | |
bool | operator== (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator!= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator< (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator> (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator<= (const PObject &obj) const |
Compare the two objects. More... | |
bool | operator>= (const PObject &obj) const |
Compare the two objects. More... | |
virtual void | PrintOn (ostream &strm) const |
Output the contents of the object to the stream. More... | |
virtual void | ReadFrom (istream &strm) |
Input the contents of the object from the stream. More... | |
Protected Member Functions | |
PSharedPtr (int dummy, const PSharedPtr *c) | |
void | AssignContents (const PContainer &c) |
Copy the container contents. More... | |
void | DestroyContents () |
Destroy the container contents. More... | |
void | CloneContents (const PContainer *src) |
void | CopyContents (const PContainer &c) |
![]() | |
PContainer (int dummy, const PContainer *cont) | |
Constructor used in support of the Clone() function. More... | |
PContainer (PContainerReference &reference) | |
Construct using static PContainerReference. More... | |
void | CopyContents (const PContainer &c) |
Copy the container contents. More... | |
void | CloneContents (const PContainer *src) |
Create a duplicate of the container contents. More... | |
void | Destruct () |
Internal function called from container destructors. More... | |
virtual void | DestroyReference () |
Destroy the PContainerReference instance. More... | |
![]() | |
PObject () | |
Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Protected Attributes | |
T * | ptr |
![]() | |
PContainerReference * | reference |
![]() | |
unsigned | m_traceContextIdentifier |
Additional Inherited Members | |
![]() | |
static const char * | Class () |
Get the name of the class as a C string. More... | |
static __inline const PObject * | PTraceObjectInstance (const char *) |
static __inline const PObject * | PTraceObjectInstance (const PObject *obj) |
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size) |
Internal function caled from CompareObjectMemoryDirect() More... | |
![]() |
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 |
|
inline |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::Reset().
|
inline |
References PSharedPtr< T >::CopyContents().
|
inline |
References PSharedPtr< T >::ptr.
|
inlinevirtual |
References PContainer::Destruct().
|
inlineprotected |
References PSharedPtr< T >::CloneContents().
|
inlineprotectedvirtual |
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.
References PContainer::AssignContents(), and PSharedPtr< T >::CopyContents().
Referenced by PSharedPtr< T >::operator=(), and PSharedPtr< T >::Reset().
|
inlineprotected |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::MakeUnique(), and PSharedPtr< T >::PSharedPtr().
|
inlineprotected |
References PSharedPtr< T >::ptr.
Referenced by PSharedPtr< T >::AssignContents(), and PSharedPtr< T >::PSharedPtr().
|
inlineprotectedvirtual |
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 PCONTAINERINFO()
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.
|
inline |
References PSharedPtr< T >::ptr.
|
inlinevirtual |
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(), and PContainer::MakeUnique().
|
inline |
References PSharedPtr< T >::ptr.
|
inline |
References PSharedPtr< T >::ptr.
|
inline |
References PSharedPtr< T >::AssignContents().
|
inline |
References PSharedPtr< T >::AssignContents(), and PSharedPtr< T >::PSharedPtr().
|
inlinevirtual |
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 true always and the new value is ignored.
Implements PContainer.
|
protected |