class KStaticDeleter

Little helper class to clean up static objects that are held as pointer. More...

Definition#include <kstaticdeleter.h>
Template formKStaticDeleter<class type>
InheritsKStaticDeleterBase [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Little helper class to clean up static objects that are held as pointer. When the library is unloaded, or the app terminated, all static deleters are destroyed, which in turn destroys those static objects properly.

A typical use is


 static KStaticDeleter sd;

 MyClass::self() {
   if (!_self) { sd.setObject(_self, new MyClass()); }
 }

 KStaticDeleter ()

KStaticDeleter

type * setObject ( type *obj, bool isArray = false)

setObject

Sets the object to delete and registers the object to be deleted to KGlobal. If the given object is 0, the former registration is unregistered.

Parameters:
isArraytells the destructor to delete an array instead of an object

type * setObject ( type* & globalRef, type *obj, bool isArray = false)

setObject

Sets the object to delete and registers the object to be deleted to KGlobal. If the given object is 0, the former registration is unregistered.

Parameters:
globalRefthe static pointer where this object is stored This pointer will be reset to 0 after deletion of the object.
isArraytells the destructor to delete an array instead of an object

void  destructObject ()

destructObject

[virtual]

Destructs the object. This has the same effect as deleting the KStaticDeleter.

Reimplemented from KStaticDeleterBase.

 ~KStaticDeleter ()

~KStaticDeleter

[virtual]


Generated by: caleb on tcdevel on Tue Jan 28 12:54:04 2003, using kdoc $.