|
imebra
build 2011-09-18_22-24-41
|
This class represents a shared pointer which keeps track of the allocated objects that derive from the class baseObject. More...
#include <baseObject.h>
Inherits puntoexe::basePtr.
Public Member Functions | |
| ptr () | |
| Default constructor. | |
| ptr (objectType *pObject) | |
| Initializes the ptr object with a reference to a baseObject. | |
| ptr (ptr< objectType > const &ptrSource) | |
| Copy constructor. | |
| ptr< objectType > & | operator= (const ptr< objectType > &ptrSource) |
| Copy the object tracked by another ptr. | |
| bool | operator== (const objectType *ptrCompare) const |
| Compare the pointer to the tracked object with the pointer specified in the parameter. | |
| bool | operator== (const ptr< objectType > &ptrCompare) const |
| Compare the pointer to the tracked object with the pointer tracked by another ptr. | |
| objectType * | operator-> () const |
| Return the pointer to the tracked object. | |
| objectType * | get () const |
| Return the pointer to the tracked object. | |
| template<class destType > | |
| operator destType * () const | |
| Return the pointer to the tracked object, type casted in the specified class pointer. | |
| template<class destType > | |
| operator ptr< destType > () const | |
| Return a new ptr object tracking the object tracked by this ptr. A type cast is performed if necessary. | |
This class represents a shared pointer which keeps track of the allocated objects that derive from the class baseObject.
Most of the classes in this library derive from baseObject.
When a ptr object is initialized with a pointer to a baseObject derived object then it increases by 1 the reference counter of baseObject.
When ptr goes out of scope (destroyed) then the reference counter of baseObject is decreased by 1, and eventually baseObject is destroyed when its reference counter reaches 0.
| puntoexe::ptr< objectType >::ptr | ( | ) | [inline] |
Default constructor.
Set the internal pointer to null.
| puntoexe::ptr< objectType >::ptr | ( | objectType * | pObject | ) | [inline] |
Initializes the ptr object with a reference to a baseObject.
The baseObject's reference counter is increased by one: this will keep the baseObject allocate at least until ptr stays allocated, release() is called or a new baseObject is associated to ptr.
| pObject | a pointer to the allocated object. The allocated object will be automatically released by the class' destructor. The object must be allocated by the C++ new statement. The object's reference counter is increased by this function. |
| puntoexe::ptr< objectType >::ptr | ( | ptr< objectType > const & | ptrSource | ) | [inline] |
Copy constructor.
The object tracked by another ptr is copied into the current ptr and the reference counter is increased.
| ptrSource | the source ptr object that must be copied into the current ptr. |
| objectType* puntoexe::ptr< objectType >::get | ( | ) | const [inline] |
Return the pointer to the tracked object.
| puntoexe::ptr< objectType >::operator destType * | ( | ) | const [inline] |
Return the pointer to the tracked object, type casted in the specified class pointer.
The cast is static, so its validity is checked at compile time.
| puntoexe::ptr< objectType >::operator ptr< destType > | ( | ) | const [inline] |
Return a new ptr object tracking the object tracked by this ptr. A type cast is performed if necessary.
The type cast is static, so its validity is checked at compile time.
| objectType* puntoexe::ptr< objectType >::operator-> | ( | ) | const [inline] |
Return the pointer to the tracked object.
| ptr<objectType>& puntoexe::ptr< objectType >::operator= | ( | const ptr< objectType > & | ptrSource | ) | [inline] |
Copy the object tracked by another ptr.
| ptrSource | the ptr object that is currently tracking the object to be tracked by this ptr object. The reference counter of the new object is increased. The object previously tracked by this ptr is released. |
| bool puntoexe::ptr< objectType >::operator== | ( | const objectType * | ptrCompare | ) | const [inline] |
Compare the pointer to the tracked object with the pointer specified in the parameter.
| ptrCompare | the pointer to be compared with the pointer to the tracked object |
| bool puntoexe::ptr< objectType >::operator== | ( | const ptr< objectType > & | ptrCompare | ) | const [inline] |
Compare the pointer to the tracked object with the pointer tracked by another ptr.
| ptrCompare | the ptr tracking the object to be compared |