#include <autoDeletable.h>
Public Member Functions |
|
Constructors and Destructors
|
|
The constructors of this class are protected.
|
|
virtual | ~AutoDeletable () |
Destructor. |
|
void * | operator new (size_t size) |
new operator. |
|
void | operator delete (void *ptr) |
delete operator. |
|
void * | operator new (size_t size, void *ptr) |
Placement new operator.
|
|
void | operator delete (void *ptr, void *) |
Placement delete operator.
|
|
Predicates
|
|
bool | isAutoDeletable () const |
Query the objects status. |
|
Protected Member Functions |
|
AutoDeletable (const AutoDeletable &auto_deletable, bool deep=false) | |
Mutators |
|
void | setAutoDeletable (bool enable) |
Mark the object as auto-deletable.
|
|
static void | clearLastPtr () |
This class allows the distinction between objects that may be deleted automatically (because they are created dynamically on the heap) and instances that are static and should not be deleted automatically.
bool BALL::AutoDeletable::isAutoDeletable | ( | ) | const |
Query the objects status.
Returns true if the object should be automatically deleted if the objects it is contained in are deleted. Recursive destruction methods should honor this flag and should not call the destructor for objects that return true.
void BALL::AutoDeletable::operator delete | ( | void * | ptr, | |
void * | ||||
) |
Placement delete operator.
This operator frees the space allocated for an Autodeletable object. It is implemented solely to achieve a consistent interface and to avoid warnings issued by some compilers if operator new/delete do not appear in pairs.
void BALL::AutoDeletable::operator delete | ( | void * | ptr | ) |
delete operator.
This operator frees the space allocated for an Autodeletable object. It is implemented solely to achieve a consistent interface and to avoid warnings issued by some compilers if operator new/delete do not appear in pairs.
void* BALL::AutoDeletable::operator new | ( | size_t | size, | |
void * | ptr | |||
) |
Placement new operator.
This operator allocates storage for the object and remembers its pointer. This pointer is static and is evaluated by the constructors. As this operator is only invoked for the creation of single dynamic objects, arrays and static objects can be identified.
void* BALL::AutoDeletable::operator new | ( | size_t | size | ) |
new operator.
This operator allocates storage for the object and remembers its pointer. This pointer is static and is evaluated by the constructors. As this operator is only invoked for the creation of single dynamic objects, arrays and static objects can be identified.
void BALL::AutoDeletable::setAutoDeletable | ( | bool | enable | ) |
Mark the object as auto-deletable.
Objects can be marked as deletable or not deletable by this method. Use this method to protect objects from automatic deletion. You should never set static objects to autodeletable, as invoking delete on a static object may result in a crash.