In use, this class is very simple. Inside a function, rather than using delete on a variable do something like this
void foo() { TAutomaticPointer<CPoint> variable = new CPoint(10, 10); // ... // Do some processing here // ... // variable is automatically delete here, which deletes the point too }
void foo() { TAutomaticPointer<CPoint> variable = new CPoint(10, 10); const long x = variable->getXPosition(); // Overloaded arrow operator returns the pointer *variable.setXPosition(x + 10); // Overloaded deference operator returns deferenced pointer }
TAutomaticPointer<CPoint> ptr(new CPoint(x,y), TObjectDeleter<CPoint>);
TAutomaticPointer<CPoint> variable = new CPoint(10, 10);
This class is intended for internal types and counted objects.
It will not work for 'built in' c++ types. If you need this functionality you can use any of the items below:
Definition at line 71 of file TAutomaticPointer.hpp.
Exponent::Collections::TAutomaticPointer< TypeName >::TAutomaticPointer | ( | TPointerDeleter< TypeName > * | pointerDeleter = &TAUTOMATICPOINTER_DEFAULT_DELETER |
) | [inline] |
Construction
pointerDeleter | The object used for addition and deletion of pointers, can be NULL for deletion of a pointer as default |
Definition at line 92 of file TAutomaticPointer.hpp.
Exponent::Collections::TAutomaticPointer< TypeName >::TAutomaticPointer | ( | TypeName * | pointer, | |
TPointerDeleter< TypeName > * | pointerDeleter = &TAUTOMATICPOINTER_DEFAULT_DELETER | |||
) | [inline] |
Construction
pointer | The pointer to store | |
pointerDeleter | The object used for addition and deletion of pointers, can be NULL for deletion of a pointer as default |
Definition at line 104 of file TAutomaticPointer.hpp.
Exponent::Collections::TAutomaticPointer< TypeName >::TAutomaticPointer | ( | const TAutomaticPointer< TypeName > & | pointer, | |
TPointerDeleter< TypeName > * | pointerDeleter = &TAUTOMATICPOINTER_DEFAULT_DELETER | |||
) | [inline] |
Copy Construction
pointer | The pointer to store | |
pointerDeleter | The object used for addition and deletion of pointers, can be NULL for deletion of a pointer as default |
Definition at line 129 of file TAutomaticPointer.hpp.
virtual Exponent::Collections::TAutomaticPointer< TypeName >::~TAutomaticPointer | ( | ) | [inline, virtual] |
Destruction
Definition at line 140 of file TAutomaticPointer.hpp.
void Exponent::Collections::TAutomaticPointer< TypeName >::freePointer | ( | ) | [inline] |
Free the pointer held internally, called automatically at destruction
Definition at line 245 of file TAutomaticPointer.hpp.
Referenced by Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::~TAutomaticPointer().
TypeName* Exponent::Collections::TAutomaticPointer< TypeName >::getMutablePointer | ( | ) | [inline] |
Get the pointer
TypeName* | The pointer |
Definition at line 270 of file TAutomaticPointer.hpp.
const TypeName* Exponent::Collections::TAutomaticPointer< TypeName >::getPointer | ( | ) | const [inline] |
Get the pointer
const | TypeName* The pointer |
Definition at line 264 of file TAutomaticPointer.hpp.
TypeName& Exponent::Collections::TAutomaticPointer< TypeName >::operator * | ( | ) | [inline] |
Deference operator
TypeName& | A reference to the inner pointer |
Definition at line 234 of file TAutomaticPointer.hpp.
TypeName* Exponent::Collections::TAutomaticPointer< TypeName >::operator-> | ( | ) | [inline] |
Pointer operator
TypeName* | A pointer to the innner data |
Definition at line 228 of file TAutomaticPointer.hpp.
TAutomaticPointer<TypeName>& Exponent::Collections::TAutomaticPointer< TypeName >::operator= | ( | TypeName * | pointer | ) | [inline] |
Assignment operator
pointer | The pointer to store |
TAutomaticPointer<TypeName>& | A reference to this |
Definition at line 189 of file TAutomaticPointer.hpp.
TAutomaticPointer<TypeName>& Exponent::Collections::TAutomaticPointer< TypeName >::operator= | ( | const TAutomaticPointer< TypeName > & | pointer | ) | [inline] |
Assignment operator
pointer | The pointer to store |
TAutomaticPointer<TypeName>& | A reference to this |
Definition at line 153 of file TAutomaticPointer.hpp.
bool Exponent::Collections::TAutomaticPointer< TypeName >::pointerIsValid | ( | ) | const [inline] |
Is the pointer valid
bool | True if pointer is non NULL, false otherwise |
Definition at line 240 of file TAutomaticPointer.hpp.
TypeName* Exponent::Collections::TAutomaticPointer< TypeName >::m_pointer [protected] |
The pointer object
Definition at line 278 of file TAutomaticPointer.hpp.
Referenced by Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::freePointer(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::getMutablePointer(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::getPointer(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::operator *(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::operator->(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::operator=(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::pointerIsValid(), and Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::TAutomaticPointer().
TPointerDeleter<TypeName>* Exponent::Collections::TAutomaticPointer< TypeName >::m_pointerDeletionHandler [protected] |
Deletion handler
Definition at line 279 of file TAutomaticPointer.hpp.
Referenced by Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::freePointer(), Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::operator=(), and Exponent::Collections::TAutomaticPointer< Exponent::GUI::Controls::CMenuItem >::TAutomaticPointer().
TCountedObjectDeleter<TypeName> Exponent::Collections::TAutomaticPointer< TypeName >::TAUTOMATICPOINTER_DEFAULT_DELETER [static] |
The default handler for pointer deletion
Definition at line 83 of file TAutomaticPointer.hpp.