#include <PhxPtr.h>
Public Member Functions | |
| Ptr (T *p) | |
| Ptr (const Ptr< T > &p) | |
| template<class Y> | |
| Ptr (const Ptr< Y > &p) | |
| const Ptr< T > & | operator= (const Ptr< T > &rhs) |
| bool | operator< (const Ptr< T > &rhs) |
| bool | operator== (const Ptr< T > &rhs) const |
| bool | operator!= (const Ptr< T > &rhs) const |
| T * | operator-> () const |
| T & | operator * () const |
| bool | operator! () const |
| operator bool () const | |
| T * | ptr () const |
| Accesses the raw pointer from within this smart-pointer. | |
| template<class Y> | |
| Ptr< Y > | dynamicCast (void) const |
| Dynamic cast convenience method. | |
| template<class Y> | |
| Ptr< Y > | staticCast (void) const |
| Static cast convenience method. | |
An "intrusive" pointer is one that operates by embedding the reference-count management into the object being pointed to. This is in contrast to the "non-intrusive" method that allocates a separate piece of shared data to manage the count.
As a result of this, not any class can be used as the template parameter T used by this Ptr type. There is a standard interface that the Ptr template requires of the object type.
void T::newReference(void) is called every time a new reference is created; that is, every time a new pointer to the object comes into existance.
void T::deleteReference(void) is called every time a reference is destroyed; that is, every time a pointer to the object goes out of scope and is destructed.
|
||||||||||||||
|
Dynamic cast convenience method. Normally, to perform a dynamic cast between smart pointers, we could do the following:
Ptr<T> t(new T());
Ptr<Y> y(dynamic_cast<Y*>(t.ptr());
This method simplifies this expression to a single call: Ptr<T> t(new T());
Ptr<Y> y(t.dynamicCast<Y>());
|
|
|||||||||
|
|
|
|||||||||
|
Accesses the raw pointer from within this smart-pointer.
|
|
||||||||||||||
|
Static cast convenience method. Normally, to perform a static cast between smart pointers, we could do the following:
Ptr<T> t(new T());
Ptr<Y> y(static_cast<Y*>(t.ptr());
This method simplifies this expression to a single call: Ptr<T> t(new T());
Ptr<Y> y(t.staticCast<Y>());
|
1.4.2