|
PTLib
Version 2.14.3
|
This is the class for pointers to objects that use the smart pointer system. More...
#include <smartptr.h>


Public Member Functions | |
Construction | |
| PSmartPointer (PSmartObject *obj=NULL) | |
Create a new smart pointer instance and have it point to the specified PSmartObject instance. More... | |
| PSmartPointer (const PSmartPointer &ptr) | |
Create a new smart pointer and point it at the data pointed to by the ptr parameter. More... | |
| virtual | ~PSmartPointer () |
| Destroy the smart pointer and decrement the reference count on the object being pointed to. More... | |
| PSmartPointer & | operator= (const PSmartPointer &ptr) |
Assign this pointer to the value specified in the ptr parameter. More... | |
Overrides from class PObject | |
| virtual Comparison | Compare (const PObject &obj) const |
| Determine the relative rank of the pointers. More... | |
Pointer access functions | |
| PBoolean | IsNULL () const |
| Determine if the smart pointer has been set to point to an actual object instance. More... | |
| PSmartObject * | GetObject () const |
| Get the current value if the internal smart object pointer. More... | |
Public Member Functions inherited from PObject | |
| 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 | 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 Attributes | |
| PSmartObject * | object |
| Object the smart pointer points to. More... | |
Protected Attributes inherited from PObject | |
| unsigned | m_traceContextIdentifier |
Additional Inherited Members | |
Public Types inherited from PObject | |
| enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 } |
Result of the comparison operation performed by the Compare() function. More... | |
Static Public Member Functions inherited from PObject | |
| 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... | |
Protected Member Functions inherited from PObject | |
| PObject () | |
| Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Friends inherited from PObject | |
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.
Note that a PSmartPointer is not 100% thread safe.
|
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 |
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 |
Determine the relative rank of the pointers.
This is identical to determining the relative rank of the integer values represented by the memory pointers.
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. | obj | Other smart pointer to compare against. |
Reimplemented from PObject.
|
inline |
Get the current value if the internal smart object pointer.
References object.
Referenced by PNotifierTemplate< PChannel::AsyncContext & >::GetTarget(), PNotifierTemplate< PChannel::AsyncContext & >::operator()(), and PNotifierListTemplate< ParamType >::IsObj::operator()().
|
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. |
|
protected |
Object the smart pointer points to.
Referenced by GetObject(), and PSmartPtr< T >::operator T *().