#include <SmartPtr.h>
Inheritance diagram for util::SmartPtr< T >:

SmartPtr provides much the same functionality as its STL counterpart auto_ptr. The main difference is that it is derived from Object. It also has some sophisticated features that are missing from auto_ptr.
Public Methods | |
| SmartPtr (const SmartPtr &other) | |
| Copy a SmartPtr instance. | |
| SmartPtr (T *ptr=NULL, bool owner=true, bool array=false) | |
| Initialize the internal pointer with ptr. | |
| ~SmartPtr () | |
| Destroy a SmartPtr instance and delete the the internal pointer if it is owned by *this. | |
| void | reset (T *ptr=NULL) |
| Set the internal pointer to a value. | |
| T * | release () const |
| Release the ownership of the internal pointer and return it. | |
| T * | get () |
| Return the internal pointer. | |
| const T * | get () const |
| Return the internal pointer. | |
| operator T * () | |
| Cast this SmartPtr to a pointer to the type of the internal pointer. | |
| operator const T * () const | |
| Cast this SmartPtr to a pointer to the type of the internal pointer. | |
| operator T & () | |
| Cast this SmartPtr to a reference of the type of the internal pointer. | |
| operator const T & () const | |
| Cast this SmartPtr to a reference of the type of the internal pointer. | |
| T & | operator * () |
| Get a reference to the object pointed to by the internal pointer. | |
| T * | operator-> () |
| Return the internal pointer. | |
| const T * | operator-> () const |
| Return the internal pointer. | |
| SmartPtr & | operator= (T *ptr) |
| Set the internal pointer to a value. | |
| SmartPtr & | operator= (const SmartPtr &other) |
| Copy another SmartPtr instance. | |
| bool | operator== (const SmartPtr< T > &other) const |
| Compare two SmartPtrs. | |
| void | setOwner (bool owner) |
| Set the ownership of the internal pointer. | |
| bool | isArray () const |
| Check whether the internal pointer is an array. | |
| void | setArray (bool array) |
| Set the type of the internal pointer. | |
|
||||||||||
|
Copy a SmartPtr instance. If other owns its internal pointer, the ownership of the pointer is transferred to *this. |
|
||||||||||||||||||||
|
Initialize the internal pointer with ptr. If owner is true (as it is by default), the new SmartPtr instance becomes the owner of the pointer, and deletes it automatically if its ownership is not explicitly released. If array is true, then delete[] is used instead of delete when the pointer needs to be destroyed. |
|
|||||||||
|
Check whether the internal pointer is an array. If it is, delete[] is used instead of delete when destroying the pointer. |
|
|||||||||
|
Cast this SmartPtr to a reference of the type of the internal pointer. (Const version) |
|
|||||||||
|
Cast this SmartPtr to a pointer to the type of the internal pointer. This method simply returns the intenal pointer. (Const version) |
|
|||||||||
|
Cast this SmartPtr to a pointer to the type of the internal pointer. This method simply returns the intenal pointer. |
|
|||||||||
|
Return the internal pointer. Const version. |
|
||||||||||
|
Copy another SmartPtr instance. If *this is owner of its internal pointer, it is deleted first. If other is owner of its internal pointer, the ownership is transferred to *this. As a result, both SmartPtr instances point to the same memory location. |
|
||||||||||
|
Set the internal pointer to a value.
|
|
||||||||||
|
Compare two SmartPtrs. Returns true if and only if the internal pointers are the same. |
|
|||||||||
|
Release the ownership of the internal pointer and return it. The internal pointer remains usable, but it is no longer owned by *this. |
|
||||||||||
|
Set the internal pointer to a value. If the current pointer is owned by *this, it is deleted. *this becomes the owner of the given pointer. The type (i.e. array/not array) of the internal pointer is assumed to remain intact. |
|
||||||||||
|
Set the type of the internal pointer.
|
|
||||||||||
|
Set the ownership of the internal pointer.
|